
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>JS开发必须知道的41个技巧 · 记录技术文档内容</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="zhengyuliang">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-sectionx/sectionx.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="JavaScript之防抖Debounce和节流Throttle.html" />
    
    
    <link rel="prev" href="ES6汇总资料.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">CSS</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../CSS/18种CSS命名和书写规范.html">
            
                <a href="../CSS/18种CSS命名和书写规范.html">
            
                    
                    18种CSS命名和书写规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../CSS/灵活运用CSS开发技巧.html">
            
                <a href="../CSS/灵活运用CSS开发技巧.html">
            
                    
                    灵活运用CSS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../CSS/自适应 flex grid.html">
            
                <a href="../CSS/自适应 flex grid.html">
            
                    
                    自适应 Flex Grid
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">HTML</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                <a href="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                    
                    浏览器里的本地数据库：IndexedDB
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Vue</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../Vue/7个有用的Vue开发技巧.html">
            
                <a href="../Vue/7个有用的Vue开发技巧.html">
            
                    
                    7个有用的Vue开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../Vue/Vue this.$router.push、replace、go的区别.html">
            
                <a href="../Vue/Vue this.$router.push、replace、go的区别.html">
            
                    
                    Vue This.$Router.Push、Replace、Go的区别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../Vue/Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                <a href="../Vue/Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                    
                    Vue 的父组件和子组件生命周期钩子函数执行顺序？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../Vue/Vue.set和this.$set应用的场景.html">
            
                <a href="../Vue/Vue.set和this.$set应用的场景.html">
            
                    
                    Vue.Set和This.$Set应用的场景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../Vue/vue高级技巧.html">
            
                <a href="../Vue/vue高级技巧.html">
            
                    
                    Vue高级技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../Vue/从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                <a href="../Vue/从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                    
                    从 0 开始手把手带你搭建一套规范的 Vue3.X 项目工程环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../Vue/浅析 vue-router 源码和动态路由权限分配.html">
            
                <a href="../Vue/浅析 vue-router 源码和动态路由权限分配.html">
            
                    
                    浅析 Vue Router 源码和动态路由权限分配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="../Vue/父组件监听到子组件的生命周期.html">
            
                <a href="../Vue/父组件监听到子组件的生命周期.html">
            
                    
                    父组件监听到子组件的生命周期
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.9" data-path="../Vue/理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                <a href="../Vue/理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                    
                    理解Vue.Mixin，利用Vue.Mixin正确的偷懒
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">JavaScript</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="5个技巧让你更好的编写 JavaScript(ES6">
            
                <span>
            
                    
                    5个技巧让你更好的编写 JavaScript(ES6) 中条件语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="5种常见函数的写法和调用方式.html">
            
                <a href="5种常见函数的写法和调用方式.html">
            
                    
                    5种常见函数的写法和调用方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="7道javascript题，让你理解基本的javascript.html">
            
                <a href="7道javascript题，让你理解基本的javascript.html">
            
                    
                    7道Javascript题，让你理解基本的Javascript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="Array.from(">
            
                <span>
            
                    
                    Array.From() 五个超好用的用途
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="ES6汇总资料.html">
            
                <a href="ES6汇总资料.html">
            
                    
                    ES6汇总资料
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="4.6" data-path="JS开发必须知道的41个技巧.html">
            
                <a href="JS开发必须知道的41个技巧.html">
            
                    
                    JS开发必须知道的41个技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="JavaScript之防抖Debounce和节流Throttle.html">
            
                <a href="JavaScript之防抖Debounce和节流Throttle.html">
            
                    
                    JavaScript之防抖Debounce和节流Throttle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="JavaScript数组求并集，交集和差集.html">
            
                <a href="JavaScript数组求并集，交集和差集.html">
            
                    
                    JavaScript数组求并集，交集和差集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.9" data-path="JavaScript的优雅写法.html">
            
                <a href="JavaScript的优雅写法.html">
            
                    
                    JavaScript的优雅写法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.10" data-path="axios知识点.html">
            
                <a href="axios知识点.html">
            
                    
                    Axios知识点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.11" data-path="javascript核心知识.html">
            
                <a href="javascript核心知识.html">
            
                    
                    Javascript核心知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.12" data-path="this、apply、call、bind.html">
            
                <a href="this、apply、call、bind.html">
            
                    
                    This、Apply、Call、Bind
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.13" data-path="前端js常用的60余种工具方法.html">
            
                <a href="前端js常用的60余种工具方法.html">
            
                    
                    前端Js常用的60余种工具方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.14" data-path="前端异常的捕获与处理.html">
            
                <a href="前端异常的捕获与处理.html">
            
                    
                    前端异常的捕获与处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.15" data-path="在 JavaScript 中交换值的 10 种方法.html">
            
                <a href="在 JavaScript 中交换值的 10 种方法.html">
            
                    
                    在 JavaScript 中交换值的 10 种方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.16" data-path="常用的前端JavaScript方法封装.html">
            
                <a href="常用的前端JavaScript方法封装.html">
            
                    
                    常用的前端JavaScript方法封装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.17" data-path="异步神器Async-await介绍与填坑.html">
            
                <a href="异步神器Async-await介绍与填坑.html">
            
                    
                    异步神器Async Await介绍与填坑
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.18" data-path="灵活运用JS开发技巧.html">
            
                <a href="灵活运用JS开发技巧.html">
            
                    
                    灵活运用JS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.19" data-path="编写高质量可维护的代码：一目了然的注释.html">
            
                <a href="编写高质量可维护的代码：一目了然的注释.html">
            
                    
                    编写高质量可维护的代码：一目了然的注释
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.20" data-path="编写高质量可维护的代码：优化逻辑判断.html">
            
                <a href="编写高质量可维护的代码：优化逻辑判断.html">
            
                    
                    编写高质量可维护的代码：优化逻辑判断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.21" data-path="编写高质量可维护的代码：优雅命名.html">
            
                <a href="编写高质量可维护的代码：优雅命名.html">
            
                    
                    编写高质量可维护的代码：优雅命名
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.22" data-path="编写高质量可维护的代码：数据建模.html">
            
                <a href="编写高质量可维护的代码：数据建模.html">
            
                    
                    编写高质量可维护的代码：数据建模
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Life Exp</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../life_exp/告别平庸的15个小方法.html">
            
                <a href="../life_exp/告别平庸的15个小方法.html">
            
                    
                    告别平庸的15个小方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../life_exp/日志记录.html">
            
                <a href="../life_exp/日志记录.html">
            
                    
                    日志记录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../life_exp/程序员的发展方向.html">
            
                <a href="../life_exp/程序员的发展方向.html">
            
                    
                    程序员的发展方向
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../message/">
            
                <a href="../message/">
            
                    
                    Message
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Technology</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../technology/WebSocket.html">
            
                <a href="../technology/WebSocket.html">
            
                    
                    WebSocket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../technology/npm常用命令大全.html">
            
                <a href="../technology/npm常用命令大全.html">
            
                    
                    Npm常用命令大全
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="../technology/智能照明项目说明.html">
            
                <a href="../technology/智能照明项目说明.html">
            
                    
                    智能照明项目说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="../technology/规范化git的提交信息.html">
            
                <a href="../technology/规范化git的提交信息.html">
            
                    
                    规范化Git的提交信息
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Tutorial</li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="../tutorial/Esmap地图详解.html">
            
                <a href="../tutorial/Esmap地图详解.html">
            
                    
                    Esmap地图详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="../tutorial/npm镜像切换.html">
            
                <a href="../tutorial/npm镜像切换.html">
            
                    
                    Npm镜像切换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="../tutorial/发布npm的教程.html">
            
                <a href="../tutorial/发布npm的教程.html">
            
                    
                    发布Npm的教程
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >JS开发必须知道的41个技巧</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <html><head></head><body><div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><ul><li><span class="title-icon "></span><a href="#js&#x5F00;&#x53D1;&#x5FC5;&#x987B;&#x77E5;&#x9053;&#x7684;41&#x4E2A;&#x6280;&#x5DE7;"><b>1.1.1. </b>JS&#x5F00;&#x53D1;&#x5FC5;&#x987B;&#x77E5;&#x9053;&#x7684;41&#x4E2A;&#x6280;&#x5DE7;</a></li></ul><li><span class="title-icon "></span><a href="#&#x524D;&#x8A00;"><b>1.2. </b>&#x524D;&#x8A00;</a></li><li><span class="title-icon "></span><a href="#array"><b>1.3. </b>Array</a></li><ul><li><span class="title-icon "></span><a href="#1&#x6570;&#x7EC4;&#x4EA4;&#x96C6;"><b>1.3.1. </b>1.&#x6570;&#x7EC4;&#x4EA4;&#x96C6;</a></li><li><span class="title-icon "></span><a href="#2&#x6570;&#x7EC4;&#x5E76;&#x96C6;"><b>1.3.2. </b>2.&#x6570;&#x7EC4;&#x5E76;&#x96C6;</a></li><li><span class="title-icon "></span><a href="#3&#x6570;&#x7EC4;&#x5DEE;&#x96C6;"><b>1.3.3. </b>3.&#x6570;&#x7EC4;&#x5DEE;&#x96C6;</a></li><li><span class="title-icon "></span><a href="#4&#x6570;&#x7EC4;&#x8865;&#x96C6;"><b>1.3.4. </b>4.&#x6570;&#x7EC4;&#x8865;&#x96C6;</a></li><li><span class="title-icon "></span><a href="#5&#x6570;&#x7EC4;&#x53BB;&#x91CD;"><b>1.3.5. </b>5.&#x6570;&#x7EC4;&#x53BB;&#x91CD;</a></li><li><span class="title-icon "></span><a href="#6&#x6570;&#x7EC4;&#x6392;&#x5E8F;"><b>1.3.6. </b>6.&#x6570;&#x7EC4;&#x6392;&#x5E8F;</a></li><li><span class="title-icon "></span><a href="#7&#x6700;&#x5927;&#x503C;"><b>1.3.7. </b>7.&#x6700;&#x5927;&#x503C;</a></li><li><span class="title-icon "></span><a href="#8&#x6570;&#x7EC4;&#x6C42;&#x548C;"><b>1.3.8. </b>8.&#x6570;&#x7EC4;&#x6C42;&#x548C;</a></li><li><span class="title-icon "></span><a href="#9&#x6570;&#x7EC4;&#x5408;&#x5E76;"><b>1.3.9. </b>9.&#x6570;&#x7EC4;&#x5408;&#x5E76;</a></li><li><span class="title-icon "></span><a href="#10&#x6570;&#x7EC4;&#x662F;&#x5426;&#x5305;&#x542B;&#x503C;"><b>1.3.10. </b>10.&#x6570;&#x7EC4;&#x662F;&#x5426;&#x5305;&#x542B;&#x503C;</a></li><li><span class="title-icon "></span><a href="#11&#x6570;&#x7EC4;&#x6BCF;&#x4E00;&#x9879;&#x90FD;&#x6EE1;&#x8DB3;"><b>1.3.11. </b>11.&#x6570;&#x7EC4;&#x6BCF;&#x4E00;&#x9879;&#x90FD;&#x6EE1;&#x8DB3;</a></li><li><span class="title-icon "></span><a href="#12&#x6570;&#x7EC4;&#x6709;&#x4E00;&#x9879;&#x6EE1;&#x8DB3;"><b>1.3.12. </b>12.&#x6570;&#x7EC4;&#x6709;&#x4E00;&#x9879;&#x6EE1;&#x8DB3;</a></li><li><span class="title-icon "></span><a href="#13&#x7248;&#x672C;&#x53F7;&#x6392;&#x5E8F;"><b>1.3.13. </b>13.&#x7248;&#x672C;&#x53F7;&#x6392;&#x5E8F;</a></li><li><span class="title-icon "></span><a href="#14-&#x5BF9;&#x8C61;&#x8F6C;&#x6570;&#x7EC4;"><b>1.3.14. </b>14. &#x5BF9;&#x8C61;&#x8F6C;&#x6570;&#x7EC4;</a></li><li><span class="title-icon "></span><a href="#15&#x6570;&#x7EC4;&#x8F6C;&#x5BF9;&#x8C61;"><b>1.3.15. </b>15.&#x6570;&#x7EC4;&#x8F6C;&#x5BF9;&#x8C61;</a></li><li><span class="title-icon "></span><a href="#16&#x6570;&#x7EC4;&#x89E3;&#x6784;"><b>1.3.16. </b>16.&#x6570;&#x7EC4;&#x89E3;&#x6784;</a></li></ul><li><span class="title-icon "></span><a href="#object"><b>1.4. </b>Object</a></li><ul><li><span class="title-icon "></span><a href="#17&#x5BF9;&#x8C61;&#x53D8;&#x91CF;&#x5C5E;&#x6027;"><b>1.4.1. </b>17.&#x5BF9;&#x8C61;&#x53D8;&#x91CF;&#x5C5E;&#x6027;</a></li><li><span class="title-icon "></span><a href="#18&#x5BF9;&#x8C61;&#x591A;&#x4F59;&#x5C5E;&#x6027;&#x5220;&#x9664;"><b>1.4.2. </b>18.&#x5BF9;&#x8C61;&#x591A;&#x4F59;&#x5C5E;&#x6027;&#x5220;&#x9664;</a></li><li><span class="title-icon "></span><a href="#19&#x5BF9;&#x8C61;&#x5D4C;&#x5957;&#x5C5E;&#x6027;&#x89E3;&#x6784;"><b>1.4.3. </b>19.&#x5BF9;&#x8C61;&#x5D4C;&#x5957;&#x5C5E;&#x6027;&#x89E3;&#x6784;</a></li><li><span class="title-icon "></span><a href="#20&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x522B;&#x540D;"><b>1.4.4. </b>20.&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x522B;&#x540D;</a></li><li><span class="title-icon "></span><a href="#21&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x9ED8;&#x8BA4;&#x503C;"><b>1.4.5. </b>21.&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x9ED8;&#x8BA4;&#x503C;</a></li><li><span class="title-icon "></span><a href="#22&#x62E6;&#x622A;&#x5BF9;&#x8C61;"><b>1.4.6. </b>22.&#x62E6;&#x622A;&#x5BF9;&#x8C61;</a></li><li><span class="title-icon "></span><a href="#23&#x5BF9;&#x8C61;&#x6DF1;&#x5EA6;&#x62F7;&#x8D1D;"><b>1.4.7. </b>23.&#x5BF9;&#x8C61;&#x6DF1;&#x5EA6;&#x62F7;&#x8D1D;</a></li><li><span class="title-icon "></span><a href="#24&#x5BF9;&#x8C61;&#x662F;&#x5426;&#x76F8;&#x7B49;"><b>1.4.8. </b>24.&#x5BF9;&#x8C61;&#x662F;&#x5426;&#x76F8;&#x7B49;</a></li><li><span class="title-icon "></span><a href="#25&#x5BF9;&#x8C61;&#x8F6C;&#x5316;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;"><b>1.4.9. </b>25.&#x5BF9;&#x8C61;&#x8F6C;&#x5316;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;</a></li></ul><li><span class="title-icon "></span><a href="#function"><b>1.5. </b>Function</a></li><ul><li><span class="title-icon "></span><a href="#26&#x51FD;&#x6570;&#x9690;&#x5F0F;&#x8FD4;&#x56DE;&#x503C;"><b>1.5.1. </b>26.&#x51FD;&#x6570;&#x9690;&#x5F0F;&#x8FD4;&#x56DE;&#x503C;</a></li><li><span class="title-icon "></span><a href="#27&#x51FD;&#x6570;&#x81EA;&#x6267;&#x884C;"><b>1.5.2. </b>27.&#x51FD;&#x6570;&#x81EA;&#x6267;&#x884C;</a></li><li><span class="title-icon "></span><a href="#28&#x51FD;&#x6570;&#x5F02;&#x6B65;&#x6267;&#x884C;"><b>1.5.3. </b>28.&#x51FD;&#x6570;&#x5F02;&#x6B65;&#x6267;&#x884C;</a></li></ul><li><span class="title-icon "></span><a href="#string"><b>1.6. </b>String</a></li><ul><li><span class="title-icon "></span><a href="#29&#x5B57;&#x7B26;&#x4E32;&#x7FFB;&#x8F6C;"><b>1.6.1. </b>29.&#x5B57;&#x7B26;&#x4E32;&#x7FFB;&#x8F6C;</a></li><li><span class="title-icon "></span><a href="#30url&#x53C2;&#x6570;&#x5E8F;&#x5217;&#x5316;"><b>1.6.2. </b>30.url&#x53C2;&#x6570;&#x5E8F;&#x5217;&#x5316;</a></li><li><span class="title-icon "></span><a href="#31url&#x53C2;&#x6570;&#x53CD;&#x5E8F;&#x5217;&#x5316;"><b>1.6.3. </b>31.url&#x53C2;&#x6570;&#x53CD;&#x5E8F;&#x5217;&#x5316;</a></li><li><span class="title-icon "></span><a href="#32&#x8F6C;&#x5316;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;"><b>1.6.4. </b>32.&#x8F6C;&#x5316;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;</a></li></ul><li><span class="title-icon "></span><a href="#number"><b>1.7. </b>Number</a></li><ul><li><span class="title-icon "></span><a href="#33&#x6570;&#x5B57;&#x5343;&#x5206;&#x4F4D;"><b>1.7.1. </b>33.&#x6570;&#x5B57;&#x5343;&#x5206;&#x4F4D;</a></li><li><span class="title-icon "></span><a href="#34&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6570;&#x5B57;"><b>1.7.2. </b>34.&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6570;&#x5B57;</a></li><li><span class="title-icon "></span><a href="#35&#x5224;&#x65AD;&#x5C0F;&#x6570;&#x662F;&#x5426;&#x76F8;&#x7B49;"><b>1.7.3. </b>35.&#x5224;&#x65AD;&#x5C0F;&#x6570;&#x662F;&#x5426;&#x76F8;&#x7B49;</a></li><li><span class="title-icon "></span><a href="#36&#x53CC;&#x4F4D;&#x8FD0;&#x7B97;&#x7B26;"><b>1.7.4. </b>36.&#x53CC;&#x4F4D;&#x8FD0;&#x7B97;&#x7B26;</a></li><li><span class="title-icon "></span><a href="#37&#x53D6;&#x6574;&#x548C;&#x5947;&#x5076;&#x6027;&#x5224;&#x65AD;"><b>1.7.5. </b>37.&#x53D6;&#x6574;&#x548C;&#x5947;&#x5076;&#x6027;&#x5224;&#x65AD;</a></li></ul><li><span class="title-icon "></span><a href="#boolean"><b>1.8. </b>Boolean</a></li><ul><li><span class="title-icon "></span><a href="#38&#x5224;&#x65AD;&#x6570;&#x636E;&#x7C7B;&#x578B;"><b>1.8.1. </b>38.&#x5224;&#x65AD;&#x6570;&#x636E;&#x7C7B;&#x578B;</a></li><li><span class="title-icon "></span><a href="#39&#x4F7F;&#x7528;boolean&#x8FC7;&#x6EE4;&#x6570;&#x7EC4;&#x5047;&#x503C;"><b>1.8.2. </b>39.&#x4F7F;&#x7528;Boolean&#x8FC7;&#x6EE4;&#x6570;&#x7EC4;&#x5047;&#x503C;</a></li><li><span class="title-icon "></span><a href="#40&#x77ED;&#x8DEF;&#x8FD0;&#x7B97;"><b>1.8.3. </b>40.&#x77ED;&#x8DEF;&#x8FD0;&#x7B97;</a></li><li><span class="title-icon "></span><a href="#41switch-&#x7B80;&#x5199;"><b>1.8.4. </b>41.switch &#x7B80;&#x5199;</a></li></ul></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h3 id="js&#x5F00;&#x53D1;&#x5FC5;&#x987B;&#x77E5;&#x9053;&#x7684;41&#x4E2A;&#x6280;&#x5DE7;"><a name="js&#x5F00;&#x53D1;&#x5FC5;&#x987B;&#x77E5;&#x9053;&#x7684;41&#x4E2A;&#x6280;&#x5DE7;" class="anchor-navigation-ex-anchor" href="#js&#x5F00;&#x53D1;&#x5FC5;&#x987B;&#x77E5;&#x9053;&#x7684;41&#x4E2A;&#x6280;&#x5DE7;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.1. JS&#x5F00;&#x53D1;&#x5FC5;&#x987B;&#x77E5;&#x9053;&#x7684;41&#x4E2A;&#x6280;&#x5DE7;</h3>
<h2 id="&#x524D;&#x8A00;"><a name="&#x524D;&#x8A00;" class="anchor-navigation-ex-anchor" href="#&#x524D;&#x8A00;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. &#x524D;&#x8A00;</h2>
<p>JS&#x662F;&#x524D;&#x7AEF;&#x7684;&#x6838;&#x5FC3;&#xFF0C;&#x4F46;&#x6709;&#x4E9B;&#x4F7F;&#x7528;&#x6280;&#x5DE7;&#x4F60;&#x8FD8;&#x4E0D;&#x4E00;&#x5B9A;&#x77E5;&#x9053;&#xFF1B;
&#x672C;&#x6587;&#x68B3;&#x7406;&#x4E86;JS&#x7684;41&#x4E2A;&#x6280;&#x5DE7;&#xFF0C;&#x5E2E;&#x52A9;&#x5927;&#x5BB6;&#x63D0;&#x9AD8;JS&#x7684;&#x4F7F;&#x7528;&#x6280;&#x5DE7;&#xFF1B;</p>
<h2 id="array"><a name="array" class="anchor-navigation-ex-anchor" href="#array"><i class="fa fa-link" aria-hidden="true"></i></a>1.3. Array</h2>
<h3 id="1&#x6570;&#x7EC4;&#x4EA4;&#x96C6;"><a name="1&#x6570;&#x7EC4;&#x4EA4;&#x96C6;" class="anchor-navigation-ex-anchor" href="#1&#x6570;&#x7EC4;&#x4EA4;&#x96C6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1. 1.&#x6570;&#x7EC4;&#x4EA4;&#x96C6;</h3>
<p>&#x666E;&#x901A;&#x6570;&#x7EC4;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr1 = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span> , <span class="hljs-number">8</span> ,<span class="hljs-number">9</span>],arr2 = [<span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>, <span class="hljs-number">9</span>];

<span class="hljs-keyword">const</span> intersection = arr1.filter(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">val</span>) </span>{ <span class="hljs-keyword">return</span> arr2.indexOf(val) &gt; <span class="hljs-number">-1</span> })
<span class="hljs-built_in">console</span>.log(intersection) <span class="hljs-comment">//[5, 8, 9]</span>
</code></pre>
<p>&#x6570;&#x7EC4;&#x5BF9;&#x8C61;
&#x6570;&#x7EC4;&#x5BF9;&#x8C61;&#x76EE;&#x524D;&#x4EC5;&#x9488;&#x5BF9;value&#x503C;&#x4E3A;&#x7B80;&#x5355;&#x7684;Number&#xFF0C;String&#xFF0C;Boolan&#x6570;&#x636E;&#x7C7B;&#x578B;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr1 = [{ <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name1&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">1</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name2&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">2</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name3&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">3</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name5&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">5</span> }];
<span class="hljs-keyword">const</span> arr2 = [{ <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name1&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">1</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name2&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">2</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name3&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">3</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name4&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">4</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name5&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">5</span> }];
<span class="hljs-keyword">const</span> result = arr2.filter(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">v</span>) </span>{
  <span class="hljs-keyword">return</span> arr1.some(<span class="hljs-function"><span class="hljs-params">n</span> =&gt;</span> <span class="hljs-built_in">JSON</span>.stringify(n) === <span class="hljs-built_in">JSON</span>.stringify(v))
})
<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">// [{ name: &apos;name1&apos;, id: 1 },{ name: &apos;name2&apos;, id: 2 },{ name: &apos;name3&apos;, id: 3 },{ name: &apos;name5&apos;, id: 5 }]</span>
</code></pre>
<h3 id="2&#x6570;&#x7EC4;&#x5E76;&#x96C6;"><a name="2&#x6570;&#x7EC4;&#x5E76;&#x96C6;" class="anchor-navigation-ex-anchor" href="#2&#x6570;&#x7EC4;&#x5E76;&#x96C6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.2. 2.&#x6570;&#x7EC4;&#x5E76;&#x96C6;</h3>
<p>&#x666E;&#x901A;&#x6570;&#x7EC4;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr1 = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">8</span>, <span class="hljs-number">9</span>]
<span class="hljs-keyword">const</span> arr2 = [<span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>, <span class="hljs-number">9</span>];
<span class="hljs-keyword">const</span> result = arr1.concat(arr2.filter(<span class="hljs-function"><span class="hljs-params">v</span> =&gt;</span> !arr1.includes(v)))
<span class="hljs-built_in">console</span>.log(result) <span class="hljs-comment">//[1, 2, 3, 4,5, 8, 9]</span>
</code></pre>
<p>&#x6570;&#x7EC4;&#x5BF9;&#x8C61;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr1 = [{ <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name1&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">1</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name2&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">2</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name3&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">3</span> }];
<span class="hljs-keyword">const</span> arr2 = [{ <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name1&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">1</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name4&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">4</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name5&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">5</span> }];
<span class="hljs-keyword">let</span> arr3 = arr1.concat(arr2);
<span class="hljs-keyword">let</span> result = [];
<span class="hljs-keyword">let</span> obj = [];
result = arr3.reduce(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">prev, cur, index, arr</span>) </span>{
  obj[cur.id] ? <span class="hljs-string">&apos;&apos;</span> : obj[cur.id] = <span class="hljs-literal">true</span> &amp;&amp; prev.push(cur);
  <span class="hljs-keyword">return</span> prev;
}, []);
<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">//[{ name: &apos;name1&apos;, id: 1 },{ name: &apos;name2&apos;, id: 2 },{ name: &apos;name3&apos;, id: 3 },{ name: &apos;name4&apos;, id: 4 },{ name: &apos;name5&apos;, id: 5 }]</span>
</code></pre>
<h3 id="3&#x6570;&#x7EC4;&#x5DEE;&#x96C6;"><a name="3&#x6570;&#x7EC4;&#x5DEE;&#x96C6;" class="anchor-navigation-ex-anchor" href="#3&#x6570;&#x7EC4;&#x5DEE;&#x96C6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.3. 3.&#x6570;&#x7EC4;&#x5DEE;&#x96C6;</h3>
<p>&#x6570;&#x7EC4;arr1&#x76F8;&#x5BF9;&#x4E8E;arr2&#x6240;&#x6CA1;&#x6709;&#x7684;
&#x666E;&#x901A;&#x6570;&#x7EC4;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr1 = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">8</span>, <span class="hljs-number">9</span>]
<span class="hljs-keyword">const</span> arr2 = [<span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>, <span class="hljs-number">9</span>];
<span class="hljs-keyword">const</span> diff = arr1.filter(<span class="hljs-function"><span class="hljs-params">item</span> =&gt;</span> !<span class="hljs-keyword">new</span> <span class="hljs-built_in">Set</span>(arr2).has(item))
<span class="hljs-built_in">console</span>.log(diff) <span class="hljs-comment">//[ 1, 2, 3, 4 ]</span>
</code></pre>
<p>&#x6570;&#x7EC4;&#x5BF9;&#x8C61;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// &#x5BF9;&#x8C61;&#x6570;&#x7EC4;</span>
<span class="hljs-keyword">let</span> arr1 = [{ <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name1&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">1</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name2&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">2</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name3&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">3</span> }];
<span class="hljs-keyword">let</span> arr2 = [{ <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name1&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">1</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name4&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">4</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name5&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">5</span> }];
<span class="hljs-keyword">let</span> result = arr1.filter(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">v</span>) </span>{
  <span class="hljs-keyword">return</span> arr2.every(<span class="hljs-function"><span class="hljs-params">n</span> =&gt;</span> <span class="hljs-built_in">JSON</span>.stringify(n) !== <span class="hljs-built_in">JSON</span>.stringify(v))
})
<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">// [ { name: &apos;name2&apos;, id: 2 }, { name: &apos;name3&apos;, id: 3 } ]</span>
</code></pre>
<h3 id="4&#x6570;&#x7EC4;&#x8865;&#x96C6;"><a name="4&#x6570;&#x7EC4;&#x8865;&#x96C6;" class="anchor-navigation-ex-anchor" href="#4&#x6570;&#x7EC4;&#x8865;&#x96C6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.4. 4.&#x6570;&#x7EC4;&#x8865;&#x96C6;</h3>
<p>&#x4E24;&#x4E2A;&#x6570;&#x7EC4;&#x5404;&#x81EA;&#x6CA1;&#x6709;&#x7684;&#x96C6;&#x5408;
&#x666E;&#x901A;&#x6570;&#x7EC4;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr1 = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">8</span>, <span class="hljs-number">9</span>]
<span class="hljs-keyword">const</span> arr2 = [<span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>, <span class="hljs-number">9</span>];
<span class="hljs-keyword">const</span> difference = <span class="hljs-built_in">Array</span>.from(<span class="hljs-keyword">new</span> <span class="hljs-built_in">Set</span>(arr1.concat(arr2).filter(<span class="hljs-function"><span class="hljs-params">v</span> =&gt;</span> !<span class="hljs-keyword">new</span> <span class="hljs-built_in">Set</span>(arr1).has(v) || !<span class="hljs-keyword">new</span> <span class="hljs-built_in">Set</span>(arr2).has(v)))) 
<span class="hljs-built_in">console</span>.log(difference) <span class="hljs-comment">//[ 1, 2, 3, 4, 6, 7 ]</span>
</code></pre>
<p>&#x6570;&#x7EC4;&#x5BF9;&#x8C61;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> arr1 = [{ <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name1&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">1</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name2&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">2</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name3&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">3</span> }];
<span class="hljs-keyword">let</span> arr2 = [{ <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name1&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">1</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name4&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">4</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name5&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">5</span> }];
<span class="hljs-keyword">let</span> arr3 = arr1.concat(arr2);
<span class="hljs-keyword">let</span> result = arr3.filter(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">v</span>) </span>{
  <span class="hljs-keyword">return</span> arr1.every(<span class="hljs-function"><span class="hljs-params">n</span> =&gt;</span> <span class="hljs-built_in">JSON</span>.stringify(n) !== <span class="hljs-built_in">JSON</span>.stringify(v)) || arr2.every(<span class="hljs-function"><span class="hljs-params">n</span> =&gt;</span> <span class="hljs-built_in">JSON</span>.stringify(n) !== <span class="hljs-built_in">JSON</span>.stringify(v))
})
<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">// [{ name: &apos;name2&apos;, id: 2 },{ name: &apos;name3&apos;, id: 3 },{ name: &apos;name4&apos;, id: 4 },{ name: &apos;name5&apos;, id: 5 }]</span>
</code></pre>
<p>&#x603B;&#x7ED3;&#x4E00;&#x4E0B;&#xFF0C;&#x5DEE;&#x96C6;&#x5C31;&#x662F;&#x6570;&#x7EC4;arr1&#x76F8;&#x5BF9;&#x4E8E;arr2&#x6240;&#x6CA1;&#x6709;&#x7684;&#x96C6;&#x5408;&#xFF0C;&#x8865;&#x96C6;&#x662F;&#x4E24;&#x4E2A;&#x6570;&#x7EC4;&#x5404;&#x81EA;&#x6CA1;&#x6709;&#x7684;&#x96C6;&#x5408;</p>
<h3 id="5&#x6570;&#x7EC4;&#x53BB;&#x91CD;"><a name="5&#x6570;&#x7EC4;&#x53BB;&#x91CD;" class="anchor-navigation-ex-anchor" href="#5&#x6570;&#x7EC4;&#x53BB;&#x91CD;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.5. 5.&#x6570;&#x7EC4;&#x53BB;&#x91CD;</h3>
<p>&#x666E;&#x901A;&#x6570;&#x7EC4;</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">Array</span>.from(<span class="hljs-keyword">new</span> <span class="hljs-built_in">Set</span>([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">4</span>]))) <span class="hljs-comment">//[1,2,3,4]</span>
<span class="hljs-built_in">console</span>.log([...new <span class="hljs-built_in">Set</span>([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">4</span>])]) <span class="hljs-comment">//[1,2,3,4]</span>
</code></pre>
<p>&#x6570;&#x7EC4;&#x5BF9;&#x8C61;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [{ <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name1&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">1</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name2&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">2</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name3&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">3</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name1&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">1</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name4&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">4</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;name5&apos;</span>, <span class="hljs-attr">id</span>: <span class="hljs-number">5</span> }];
 <span class="hljs-keyword">const</span> result = [];
 arr.forEach(<span class="hljs-function"><span class="hljs-params">item</span>=&gt;</span>{
    !result.some(<span class="hljs-function"><span class="hljs-params">v</span> =&gt;</span> <span class="hljs-built_in">JSON</span>.stringify(v) === <span class="hljs-built_in">JSON</span>.stringify(item)) &amp;&amp; result.push(item)
 })
 <span class="hljs-built_in">console</span>.log(result) <span class="hljs-comment">//[{ name: &apos;name1&apos;, id: 1 },{ name: &apos;name2&apos;, id: 2 },{ name: &apos;name3&apos;, id: 3 },{ name: &apos;name4&apos;, id: 4 },{ name: &apos;name5&apos;, id: 5 }]</span>
</code></pre>
<h3 id="6&#x6570;&#x7EC4;&#x6392;&#x5E8F;"><a name="6&#x6570;&#x7EC4;&#x6392;&#x5E8F;" class="anchor-navigation-ex-anchor" href="#6&#x6570;&#x7EC4;&#x6392;&#x5E8F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.6. 6.&#x6570;&#x7EC4;&#x6392;&#x5E8F;</h3>
<p>&#x666E;&#x901A;&#x6570;&#x7EC4;</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">console</span>.log([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>].sort(<span class="hljs-function">(<span class="hljs-params">a, b</span>) =&gt;</span> a - b)); <span class="hljs-comment">// [1, 2,3,4] &#x5347;&#x5E8F;</span>
<span class="hljs-built_in">console</span>.log([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>].sort(<span class="hljs-function">(<span class="hljs-params">a, b</span>) =&gt;</span> b - a)); <span class="hljs-comment">// [4,3,2,1] &#x964D;&#x5E8F;</span>
</code></pre>
<p>&#x6570;&#x7EC4;&#x5BF9;&#x8C61;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr1 = [{ <span class="hljs-attr">name</span>: <span class="hljs-string">&quot;Rom&quot;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">12</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&quot;Bob&quot;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">22</span> }].sort(<span class="hljs-function">(<span class="hljs-params">a, b</span>) =&gt;</span> { <span class="hljs-keyword">return</span> a.age - b.age })<span class="hljs-comment">//&#x5347;&#x5E8F;</span>
<span class="hljs-keyword">const</span> arr2 = [{ <span class="hljs-attr">name</span>: <span class="hljs-string">&quot;Rom&quot;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">12</span> }, { <span class="hljs-attr">name</span>: <span class="hljs-string">&quot;Bob&quot;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">22</span> }].sort(<span class="hljs-function">(<span class="hljs-params">a, b</span>) =&gt;</span> { <span class="hljs-keyword">return</span> -a.age + b.age })<span class="hljs-comment">//&#x964D;&#x5E8F;</span>
<span class="hljs-built_in">console</span>.log(arr2) <span class="hljs-comment">// [{ name: &apos;Bob&apos;, age:22 }, { name: &apos;Rom&apos;, age: 12 }]</span>
<span class="hljs-built_in">console</span>.log(arr1) <span class="hljs-comment">// [ { name: &apos;Rom&apos;, age: 12 }, { name: &apos;Bob&apos;, age: 22 } ]</span>
</code></pre>
<p>&#x4E24;&#x4E2A;&#x79CD;&#x7C7B;&#x578B;&#x6570;&#x7EC4;&#x90FD;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;sort&#x6392;&#x5E8F;&#xFF0C;sort&#x662F;&#x6D4F;&#x89C8;&#x5668;&#x5185;&#x7F6E;&#x65B9;&#x6CD5;&#xFF1B;
&#x9ED8;&#x8BA4;&#x662F;&#x5347;&#x5E8F;&#x6392;&#x5E8F;&#xFF0C;&#x9ED8;&#x8BA4;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#xFF0C;&#x6709;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#xFF1A;
(a, b) =&gt; a - b &#x662F;&#x5347;&#x5E8F;&#xFF1B;
(a, b) =&gt; b - a &#x662F;&#x964D;&#x5E8F;&#x3002;</p>
<h3 id="7&#x6700;&#x5927;&#x503C;"><a name="7&#x6700;&#x5927;&#x503C;" class="anchor-navigation-ex-anchor" href="#7&#x6700;&#x5927;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.7. 7.&#x6700;&#x5927;&#x503C;</h3>
<p>&#x666E;&#x901A;&#x6570;&#x7EC4;</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">Math</span>.max(...[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>]) <span class="hljs-comment">//4</span>
<span class="hljs-built_in">Math</span>.max.apply(<span class="hljs-keyword">this</span>, [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>]) <span class="hljs-comment">//4</span>
[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>].reduce(<span class="hljs-function">(<span class="hljs-params">prev, cur, curIndex, arr</span>) =&gt;</span> {
   <span class="hljs-keyword">return</span> <span class="hljs-built_in">Math</span>.max(prev, cur);
}, <span class="hljs-number">0</span>) <span class="hljs-comment">//4</span>
</code></pre>
<p>&#x53D6;&#x6570;&#x7EC4;&#x5BF9;&#x8C61;&#x4E2D;id&#x7684;&#x6700;&#x5927;&#x503C;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [{ <span class="hljs-attr">id</span>: <span class="hljs-number">1</span>, <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;jack&apos;</span> },{ <span class="hljs-attr">id</span>: <span class="hljs-number">2</span>, <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;may&apos;</span> },{ <span class="hljs-attr">id</span>: <span class="hljs-number">3</span>, <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;shawn&apos;</span> },{ <span class="hljs-attr">id</span>: <span class="hljs-number">4</span>, <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;tony&apos;</span> }]
<span class="hljs-keyword">const</span> arr1 = <span class="hljs-built_in">Math</span>.max.apply(<span class="hljs-built_in">Math</span>, arr.map(<span class="hljs-function"><span class="hljs-params">item</span> =&gt;</span> { <span class="hljs-keyword">return</span> item.id }))
<span class="hljs-keyword">const</span> arr2 = arr.sort(<span class="hljs-function">(<span class="hljs-params">a, b</span>) =&gt;</span> { <span class="hljs-keyword">return</span> b.id - a.id })[<span class="hljs-number">0</span>].id
<span class="hljs-built_in">console</span>.log(arr1) <span class="hljs-comment">// 4</span>
<span class="hljs-built_in">console</span>.log(arr2) <span class="hljs-comment">// 4</span>
</code></pre>
<h3 id="8&#x6570;&#x7EC4;&#x6C42;&#x548C;"><a name="8&#x6570;&#x7EC4;&#x6C42;&#x548C;" class="anchor-navigation-ex-anchor" href="#8&#x6570;&#x7EC4;&#x6C42;&#x548C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.8. 8.&#x6570;&#x7EC4;&#x6C42;&#x548C;</h3>
<p>&#x666E;&#x901A;&#x6570;&#x7EC4;</p>
<pre><code class="lang-javascript">[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>].reduce(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">prev, cur</span>) </span>{
  <span class="hljs-keyword">return</span> prev + cur;
}, <span class="hljs-number">0</span>) <span class="hljs-comment">//10</span>
</code></pre>
<p>&#x6570;&#x7EC4;&#x5BF9;&#x8C61;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> sum = [{<span class="hljs-attr">age</span>:<span class="hljs-number">1</span>},{<span class="hljs-attr">age</span>:<span class="hljs-number">2</span>}].reduce(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">prev, cur</span>) </span>{
  <span class="hljs-keyword">return</span> prev + cur.age;
}, <span class="hljs-number">0</span>) <span class="hljs-comment">//3</span>
<span class="hljs-built_in">console</span>.log(sum)
</code></pre>
<h3 id="9&#x6570;&#x7EC4;&#x5408;&#x5E76;"><a name="9&#x6570;&#x7EC4;&#x5408;&#x5E76;" class="anchor-navigation-ex-anchor" href="#9&#x6570;&#x7EC4;&#x5408;&#x5E76;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.9. 9.&#x6570;&#x7EC4;&#x5408;&#x5E76;</h3>
<p>&#x666E;&#x901A;&#x6570;&#x7EC4;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr1 =[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>].concat([<span class="hljs-number">5</span>, <span class="hljs-number">6</span>]) <span class="hljs-comment">//[1,2,3,4,5,6]</span>
<span class="hljs-keyword">const</span> arr2 =[...[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>],...[<span class="hljs-number">4</span>, <span class="hljs-number">5</span>]] <span class="hljs-comment">//[1,2,3,4,5,6]</span>
<span class="hljs-keyword">const</span> arrA = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>], arrB = [<span class="hljs-number">3</span>, <span class="hljs-number">4</span>]
<span class="hljs-keyword">const</span> arr3 =[].concat.apply(arrA, arrB)<span class="hljs-comment">//arrA&#x503C;&#x4E3A;[1,2,3,4]</span>
</code></pre>
<p>&#x6570;&#x7EC4;&#x5BF9;&#x8C61;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr4 = [{ <span class="hljs-attr">age</span>: <span class="hljs-number">1</span> }].concat([{ <span class="hljs-attr">age</span>: <span class="hljs-number">2</span> }])
<span class="hljs-keyword">const</span> arr5 = [...[{ <span class="hljs-attr">age</span>: <span class="hljs-number">1</span> }],...[{ <span class="hljs-attr">age</span>: <span class="hljs-number">2</span> }]]
<span class="hljs-built_in">console</span>.log(arr4) <span class="hljs-comment">//[ { age: 1 }, { age: 2 } ]</span>
<span class="hljs-built_in">console</span>.log(arr5) <span class="hljs-comment">// [ { age: 1 }, { age: 2 } ]</span>
</code></pre>
<h3 id="10&#x6570;&#x7EC4;&#x662F;&#x5426;&#x5305;&#x542B;&#x503C;"><a name="10&#x6570;&#x7EC4;&#x662F;&#x5426;&#x5305;&#x542B;&#x503C;" class="anchor-navigation-ex-anchor" href="#10&#x6570;&#x7EC4;&#x662F;&#x5426;&#x5305;&#x542B;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.10. 10.&#x6570;&#x7EC4;&#x662F;&#x5426;&#x5305;&#x542B;&#x503C;</h3>
<p>&#x666E;&#x901A;&#x6570;&#x7EC4;</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">console</span>.log([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>].includes(<span class="hljs-number">4</span>)) <span class="hljs-comment">//false</span>
<span class="hljs-built_in">console</span>.log([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>].indexOf(<span class="hljs-number">4</span>)) <span class="hljs-comment">//-1 &#x5982;&#x679C;&#x5B58;&#x5728;&#x6362;&#x56DE;&#x7D22;&#x5F15;</span>
<span class="hljs-built_in">console</span>.log([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>].find(<span class="hljs-function">(<span class="hljs-params">item</span>) =&gt;</span> item === <span class="hljs-number">3</span>)) <span class="hljs-comment">//3 &#x5982;&#x679C;&#x6570;&#x7EC4;&#x4E2D;&#x65E0;&#x503C;&#x8FD4;&#x56DE;undefined</span>
<span class="hljs-built_in">console</span>.log([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>].findIndex(<span class="hljs-function">(<span class="hljs-params">item</span>) =&gt;</span> item === <span class="hljs-number">3</span>)) <span class="hljs-comment">//2 &#x5982;&#x679C;&#x6570;&#x7EC4;&#x4E2D;&#x65E0;&#x503C;&#x8FD4;&#x56DE;-1</span>
</code></pre>
<p>&#x6570;&#x7EC4;&#x5BF9;&#x8C61;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> flag = [{<span class="hljs-attr">age</span>:<span class="hljs-number">1</span>},{<span class="hljs-attr">age</span>:<span class="hljs-number">2</span>}].some(<span class="hljs-function"><span class="hljs-params">v</span>=&gt;</span><span class="hljs-built_in">JSON</span>.stringify(v)===<span class="hljs-built_in">JSON</span>.stringify({<span class="hljs-attr">age</span>:<span class="hljs-number">2</span>}))
<span class="hljs-built_in">console</span>.log(flag)
</code></pre>
<h3 id="11&#x6570;&#x7EC4;&#x6BCF;&#x4E00;&#x9879;&#x90FD;&#x6EE1;&#x8DB3;"><a name="11&#x6570;&#x7EC4;&#x6BCF;&#x4E00;&#x9879;&#x90FD;&#x6EE1;&#x8DB3;" class="anchor-navigation-ex-anchor" href="#11&#x6570;&#x7EC4;&#x6BCF;&#x4E00;&#x9879;&#x90FD;&#x6EE1;&#x8DB3;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.11. 11.&#x6570;&#x7EC4;&#x6BCF;&#x4E00;&#x9879;&#x90FD;&#x6EE1;&#x8DB3;</h3>
<p>&#x666E;&#x901A;&#x6570;&#x7EC4;</p>
<pre><code class="lang-javascript">[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>].every(<span class="hljs-function"><span class="hljs-params">item</span> =&gt;</span> { <span class="hljs-keyword">return</span> item &gt; <span class="hljs-number">2</span> })
</code></pre>
<p>&#x6570;&#x7EC4;&#x5BF9;&#x8C61;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [{ <span class="hljs-attr">age</span>: <span class="hljs-number">3</span> }, { <span class="hljs-attr">age</span>: <span class="hljs-number">4</span> }, { <span class="hljs-attr">age</span>: <span class="hljs-number">5</span> }]
arr.every(<span class="hljs-function"><span class="hljs-params">item</span> =&gt;</span> { <span class="hljs-keyword">return</span> item.age &gt; <span class="hljs-number">2</span> }) <span class="hljs-comment">// true</span>
</code></pre>
<h3 id="12&#x6570;&#x7EC4;&#x6709;&#x4E00;&#x9879;&#x6EE1;&#x8DB3;"><a name="12&#x6570;&#x7EC4;&#x6709;&#x4E00;&#x9879;&#x6EE1;&#x8DB3;" class="anchor-navigation-ex-anchor" href="#12&#x6570;&#x7EC4;&#x6709;&#x4E00;&#x9879;&#x6EE1;&#x8DB3;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.12. 12.&#x6570;&#x7EC4;&#x6709;&#x4E00;&#x9879;&#x6EE1;&#x8DB3;</h3>
<p>&#x666E;&#x901A;&#x6570;&#x7EC4;</p>
<pre><code class="lang-javascript">[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>].some(<span class="hljs-function"><span class="hljs-params">item</span> =&gt;</span> { <span class="hljs-keyword">return</span> item &gt; <span class="hljs-number">2</span> })
</code></pre>
<p>&#x6570;&#x7EC4;&#x5BF9;&#x8C61;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [{ <span class="hljs-attr">age</span>: <span class="hljs-number">3</span> }, { <span class="hljs-attr">age</span>: <span class="hljs-number">4</span> }, { <span class="hljs-attr">age</span>: <span class="hljs-number">5</span> }]
arr.some(<span class="hljs-function"><span class="hljs-params">item</span> =&gt;</span> { <span class="hljs-keyword">return</span> item.age &lt; <span class="hljs-number">4</span> }) <span class="hljs-comment">// true</span>
</code></pre>
<h3 id="13&#x7248;&#x672C;&#x53F7;&#x6392;&#x5E8F;"><a name="13&#x7248;&#x672C;&#x53F7;&#x6392;&#x5E8F;" class="anchor-navigation-ex-anchor" href="#13&#x7248;&#x672C;&#x53F7;&#x6392;&#x5E8F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.13. 13.&#x7248;&#x672C;&#x53F7;&#x6392;&#x5E8F;</h3>
<p>&#x65B9;&#x6CD5;&#x4E00;</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sortNumber</span>(<span class="hljs-params">a, b</span>) </span>{
  <span class="hljs-keyword">return</span> a - b
}
<span class="hljs-keyword">const</span> b = [<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">7</span>,<span class="hljs-number">5</span>,<span class="hljs-number">6</span>]
<span class="hljs-keyword">const</span> a = [<span class="hljs-string">&quot;1.5&quot;</span>, <span class="hljs-string">&quot;1.5&quot;</span>, <span class="hljs-string">&quot;1.40&quot;</span>, <span class="hljs-string">&quot;1.25&quot;</span>, <span class="hljs-string">&quot;1.1000&quot;</span>, <span class="hljs-string">&quot;1.1&quot;</span>];

<span class="hljs-built_in">console</span>.log(a.sort(sortNumber)); <span class="hljs-comment">// [ 1, 2, 3, 5, 6, 7 ]</span>
<span class="hljs-built_in">console</span>.log(b.sort(sortNumber)); <span class="hljs-comment">//[ &apos;1.1000&apos;, &apos;1.1&apos;, &apos;1.25&apos;, &apos;1.40&apos;, &apos;1.5&apos;, &apos;1.5&apos; ]</span>
</code></pre>
<p>&#x53EF;&#x89C1;sort&#x6392;&#x5E8F;&#x5BF9;&#x6574;&#x6570;&#x53EF;&#x4EE5;&#xFF0C;&#x7C7B;&#x4F3C;&#x7248;&#x672C;&#x53F7;&#x8FD9;&#x4E2A;&#x683C;&#x5F0F;&#x5C31;&#x4E0D;&#x9002;&#x7528;&#x4E86;&#xFF0C;&#x56E0;&#x4E3A;sort&#x51FD;&#x6570;&#x5728;&#x6BD4;&#x8F83;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x662F;&#x6BD4;&#x8F83;&#x5B57;&#x7B26;&#x4E32;&#x7684;Unicode&#x8FDB;&#x884C;&#x6392;&#x5E8F;&#x7684;&#x3002;</p>
<p>&#x65B9;&#x6CD5;&#x4E8C;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">//&#x5047;&#x5B9A;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x6BCF;&#x8282;&#x6570;&#x90FD;&#x5728;5&#x4F4D;&#x4EE5;&#x4E0B;</span>
<span class="hljs-comment">//&#x53BB;&#x9664;&#x6570;&#x7EC4;&#x7A7A;&#x503C;||&#x7A7A;&#x683C;</span>
<span class="hljs-keyword">if</span> (!<span class="hljs-built_in">Array</span>.prototype.trim) {
  <span class="hljs-built_in">Array</span>.prototype.trim = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">let</span> arr = []; <span class="hljs-keyword">this</span>.forEach(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">e</span>) </span>{
      <span class="hljs-keyword">if</span> (e.match(<span class="hljs-regexp">/\S+/</span>)) arr.push(e);
    })
    <span class="hljs-keyword">return</span> arr;
  }
}

<span class="hljs-comment">//&#x63D0;&#x53D6;&#x6570;&#x5B57;&#x90E8;&#x5206;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">toNum</span>(<span class="hljs-params">a</span>) </span>{
  <span class="hljs-keyword">let</span> d = a.toString();
  <span class="hljs-keyword">let</span> c = d.split(<span class="hljs-regexp">/\D/</span>).trim();
  <span class="hljs-keyword">let</span> num_place = [<span class="hljs-string">&quot;&quot;</span>, <span class="hljs-string">&quot;0&quot;</span>, <span class="hljs-string">&quot;00&quot;</span>, <span class="hljs-string">&quot;000&quot;</span>, <span class="hljs-string">&quot;0000&quot;</span>], r = num_place.reverse();
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; c.length; i++) {
    <span class="hljs-keyword">let</span> len = c[i].length;
    c[i] = r[len] + c[i];
  }
  <span class="hljs-keyword">let</span> res = c.join(<span class="hljs-string">&apos;&apos;</span>);
  <span class="hljs-keyword">return</span> res;
}

<span class="hljs-comment">//&#x63D0;&#x53D6;&#x5B57;&#x7B26;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">toChar</span>(<span class="hljs-params">a</span>) </span>{
  <span class="hljs-keyword">let</span> d = a.toString();
  <span class="hljs-keyword">let</span> c = d.split(<span class="hljs-regexp">/\.|\d/</span>).join(<span class="hljs-string">&apos;&apos;</span>);
  <span class="hljs-keyword">return</span> c;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sortVersions</span>(<span class="hljs-params">a, b</span>) </span>{

  <span class="hljs-keyword">let</span> _a1 = toNum(a), _b1 = toNum(b);
  <span class="hljs-keyword">if</span> (_a1 !== _b1) <span class="hljs-keyword">return</span> _a1 - _b1;
  <span class="hljs-keyword">else</span> {
    _a2 = toChar(a).charCodeAt(<span class="hljs-number">0</span>).toString(<span class="hljs-number">16</span>);
    _b2 = toChar(b).charCodeAt(<span class="hljs-number">0</span>).toString(<span class="hljs-number">16</span>);
    <span class="hljs-keyword">return</span> _a2 - _b2;
  }
}

<span class="hljs-keyword">let</span> arr1 = [<span class="hljs-string">&quot;10&quot;</span>, <span class="hljs-string">&quot;5&quot;</span>, <span class="hljs-string">&quot;40&quot;</span>, <span class="hljs-string">&quot;25&quot;</span>, <span class="hljs-string">&quot;1000&quot;</span>, <span class="hljs-string">&quot;1&quot;</span>];
<span class="hljs-keyword">let</span> arr2 = [<span class="hljs-string">&quot;1.10&quot;</span>, <span class="hljs-string">&quot;1.5&quot;</span>, <span class="hljs-string">&quot;1.40&quot;</span>, <span class="hljs-string">&quot;1.25&quot;</span>, <span class="hljs-string">&quot;1.1000&quot;</span>, <span class="hljs-string">&quot;1.1&quot;</span>];
<span class="hljs-keyword">let</span> arr3 = [<span class="hljs-string">&quot;1.10c&quot;</span>, <span class="hljs-string">&quot;1.10b&quot;</span>, <span class="hljs-string">&quot;1.10C&quot;</span>, <span class="hljs-string">&quot;1.25&quot;</span>, <span class="hljs-string">&quot;1.1000&quot;</span>, <span class="hljs-string">&quot;1.10A&quot;</span>];
<span class="hljs-built_in">console</span>.log(arr1.sort(sortVersions)) <span class="hljs-comment">//[ &apos;1&apos;, &apos;5&apos;, &apos;10&apos;, &apos;25&apos;, &apos;40&apos;, &apos;1000&apos; ]</span>
<span class="hljs-built_in">console</span>.log(arr2.sort(sortVersions)) <span class="hljs-comment">//[ &apos;1.1&apos;, &apos;1.5&apos;, &apos;1.10&apos;, &apos;1.25&apos;, &apos;1.40&apos;, &apos;1.1000&apos; ]</span>
<span class="hljs-built_in">console</span>.log(arr3.sort(sortVersions)) <span class="hljs-comment">// [ &apos;1.10A&apos;, &apos;1.10C&apos;, &apos;1.10b&apos;, &apos;1.10c&apos;, &apos;1.25&apos;, &apos;1.1000&apos; ]</span>
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x51FA;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x5747;&#x517C;&#x5BB9;&#x6574;&#x6570;&#xFF0C;&#x975E;&#x6574;&#x6570;&#xFF0C;&#x5B57;&#x6BCD;&#xFF1B;
&#x5B57;&#x6BCD;&#x6392;&#x5E8F;&#x662F;&#x6839;&#x636E;Unicode&#x6392;&#x5E8F;&#x7684;&#xFF0C;&#x6240;&#x4EE5;1.10b&#x5728;1.10C&#x7684;&#x540E;&#x9762;</p>
<h3 id="14-&#x5BF9;&#x8C61;&#x8F6C;&#x6570;&#x7EC4;"><a name="14-&#x5BF9;&#x8C61;&#x8F6C;&#x6570;&#x7EC4;" class="anchor-navigation-ex-anchor" href="#14-&#x5BF9;&#x8C61;&#x8F6C;&#x6570;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.14. 14. &#x5BF9;&#x8C61;&#x8F6C;&#x6570;&#x7EC4;</h3>
<p>&#x5C06;&#x6570;&#x7EC4;&#x7684;key&#x548C;value&#x8F6C;&#x5316;&#x6210;&#x6570;&#x7EC4;</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">Object</span>.keys({ <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;&#x5F20;&#x4E09;&apos;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">14</span> }) <span class="hljs-comment">//[&apos;name&apos;,&apos;age&apos;]</span>
<span class="hljs-built_in">Object</span>.values({ <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;&#x5F20;&#x4E09;&apos;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">14</span> }) <span class="hljs-comment">//[&apos;&#x5F20;&#x4E09;&apos;,14]</span>
<span class="hljs-built_in">Object</span>.entries({ <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;&#x5F20;&#x4E09;&apos;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">14</span> }) <span class="hljs-comment">//[[name,&apos;&#x5F20;&#x4E09;&apos;],[age,14]]</span>
<span class="hljs-built_in">Object</span>.fromEntries([name, <span class="hljs-string">&apos;&#x5F20;&#x4E09;&apos;</span>], [age, <span class="hljs-number">14</span>]) <span class="hljs-comment">//ES10&#x7684;api,Chrome&#x4E0D;&#x652F;&#x6301; , firebox&#x8F93;&#x51FA;{name:&apos;&#x5F20;&#x4E09;&apos;,age:14}</span>
</code></pre>
<h3 id="15&#x6570;&#x7EC4;&#x8F6C;&#x5BF9;&#x8C61;"><a name="15&#x6570;&#x7EC4;&#x8F6C;&#x5BF9;&#x8C61;" class="anchor-navigation-ex-anchor" href="#15&#x6570;&#x7EC4;&#x8F6C;&#x5BF9;&#x8C61;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.15. 15.&#x6570;&#x7EC4;&#x8F6C;&#x5BF9;&#x8C61;</h3>
<p>&#x5C06;&#x6570;&#x7EC4;&#x7684;&#x503C;&#x8F6C;&#x5316;&#x4E3A;&#x5BF9;&#x8C61;&#x7684;value</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arrName = [<span class="hljs-string">&apos;&#x5F20;&#x4E09;&apos;</span>, <span class="hljs-string">&apos;&#x674E;&#x56DB;&apos;</span>, <span class="hljs-string">&apos;&#x738B;&#x4E94;&apos;</span>]
<span class="hljs-keyword">const</span> arrAge=[<span class="hljs-string">&apos;20&apos;</span>,<span class="hljs-string">&apos;30&apos;</span>,<span class="hljs-string">&apos;40&apos;</span>]
<span class="hljs-keyword">const</span> arrDec = [<span class="hljs-string">&apos;&#x63CF;&#x8FF0;1&apos;</span>, <span class="hljs-string">&apos;&#x63CF;&#x8FF0;2&apos;</span>, <span class="hljs-string">&apos;&#x63CF;&#x8FF0;3&apos;</span>]
<span class="hljs-keyword">const</span> obj = arrName.map(<span class="hljs-function">(<span class="hljs-params">item,index</span>)=&gt;</span>{
  <span class="hljs-keyword">return</span> { <span class="hljs-attr">name</span>: item, <span class="hljs-attr">age</span>: arrAge[index],<span class="hljs-attr">dec</span>:arrDec[index]}
})

<span class="hljs-built_in">console</span>.log(obj) <span class="hljs-comment">// [{ name: &apos;&#x5F20;&#x4E09;&apos;, age: &apos;20&apos;, dec: &apos;&#x63CF;&#x8FF0;1&apos; },{ name: &apos;&#x674E;&#x56DB;&apos;, age: &apos;30&apos;, dec: &apos;&#x63CF;&#x8FF0;2&apos; },{ name: &apos;&#x738B;&#x4E94;&apos;, age: &apos;40&apos;, dec: &apos;&#x63CF;&#x8FF0;3&apos; }]</span>
</code></pre>
<h3 id="16&#x6570;&#x7EC4;&#x89E3;&#x6784;"><a name="16&#x6570;&#x7EC4;&#x89E3;&#x6784;" class="anchor-navigation-ex-anchor" href="#16&#x6570;&#x7EC4;&#x89E3;&#x6784;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.16. 16.&#x6570;&#x7EC4;&#x89E3;&#x6784;</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr=[<span class="hljs-number">1</span>,<span class="hljs-number">2</span>]; <span class="hljs-comment">//&#x540E;&#x9762;&#x4E00;&#x5B9A;&#x8981;&#x52A0;&#x5206;&#x53F7;&#xFF0C;&#x56E0;&#x4E3A;&#x4E0D;&#x52A0;&#x89E3;&#x91CA;&#x5668;&#x4F1A;&#x8BA4;&#x4E3A;&#x5728;&#x8BFB;&#x6570;&#x7EC4;</span>
[arr[<span class="hljs-number">1</span>], arr[<span class="hljs-number">0</span>]] = [arr[<span class="hljs-number">0</span>], arr[<span class="hljs-number">1</span>]]; <span class="hljs-comment">// [2,1]</span>
</code></pre>
<h2 id="object"><a name="object" class="anchor-navigation-ex-anchor" href="#object"><i class="fa fa-link" aria-hidden="true"></i></a>1.4. Object</h2>
<h3 id="17&#x5BF9;&#x8C61;&#x53D8;&#x91CF;&#x5C5E;&#x6027;"><a name="17&#x5BF9;&#x8C61;&#x53D8;&#x91CF;&#x5C5E;&#x6027;" class="anchor-navigation-ex-anchor" href="#17&#x5BF9;&#x8C61;&#x53D8;&#x91CF;&#x5C5E;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.1. 17.&#x5BF9;&#x8C61;&#x53D8;&#x91CF;&#x5C5E;&#x6027;</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> flag = <span class="hljs-literal">true</span>;
<span class="hljs-keyword">const</span> obj = {
    <span class="hljs-attr">a</span>: <span class="hljs-number">0</span>,
    [flag ? <span class="hljs-string">&quot;c&quot;</span> : <span class="hljs-string">&quot;d&quot;</span>]: <span class="hljs-number">2</span>
};
<span class="hljs-comment">// obj =&gt; { a: 0, c: 2 }</span>
</code></pre>
<h3 id="18&#x5BF9;&#x8C61;&#x591A;&#x4F59;&#x5C5E;&#x6027;&#x5220;&#x9664;"><a name="18&#x5BF9;&#x8C61;&#x591A;&#x4F59;&#x5C5E;&#x6027;&#x5220;&#x9664;" class="anchor-navigation-ex-anchor" href="#18&#x5BF9;&#x8C61;&#x591A;&#x4F59;&#x5C5E;&#x6027;&#x5220;&#x9664;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.2. 18.&#x5BF9;&#x8C61;&#x591A;&#x4F59;&#x5C5E;&#x6027;&#x5220;&#x9664;</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> { name, age, ...obj } = { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;&#x5F20;&#x4E09;&apos;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">13</span>, <span class="hljs-attr">dec</span>: <span class="hljs-string">&apos;&#x63CF;&#x8FF0;1&apos;</span>, <span class="hljs-attr">info</span>: <span class="hljs-string">&apos;&#x4FE1;&#x606F;&apos;</span> }
<span class="hljs-built_in">console</span>.log(name)  <span class="hljs-comment">// &#x5F20;&#x4E09;</span>
<span class="hljs-built_in">console</span>.log(age)  <span class="hljs-comment">// 13</span>
<span class="hljs-built_in">console</span>.log(obj)  <span class="hljs-comment">// {dec: &apos;&#x63CF;&#x8FF0;1&apos;, info: &apos;&#x4FE1;&#x606F;&apos; }</span>
</code></pre>
<h3 id="19&#x5BF9;&#x8C61;&#x5D4C;&#x5957;&#x5C5E;&#x6027;&#x89E3;&#x6784;"><a name="19&#x5BF9;&#x8C61;&#x5D4C;&#x5957;&#x5C5E;&#x6027;&#x89E3;&#x6784;" class="anchor-navigation-ex-anchor" href="#19&#x5BF9;&#x8C61;&#x5D4C;&#x5957;&#x5C5E;&#x6027;&#x89E3;&#x6784;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3. 19.&#x5BF9;&#x8C61;&#x5D4C;&#x5957;&#x5C5E;&#x6027;&#x89E3;&#x6784;</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> { <span class="hljs-attr">info</span>:{ dec} } = { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;&#x5F20;&#x4E09;&apos;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">13</span>, <span class="hljs-attr">info</span>:{<span class="hljs-attr">dec</span>: <span class="hljs-string">&apos;&#x63CF;&#x8FF0;1&apos;</span>, <span class="hljs-attr">info</span>: <span class="hljs-string">&apos;&#x4FE1;&#x606F;&apos;</span> }}
<span class="hljs-built_in">console</span>.log(dec) <span class="hljs-comment">// &#x63CF;&#x8FF0;1</span>
</code></pre>
<h3 id="20&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x522B;&#x540D;"><a name="20&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x522B;&#x540D;" class="anchor-navigation-ex-anchor" href="#20&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x522B;&#x540D;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.4. 20.&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x522B;&#x540D;</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> { <span class="hljs-attr">name</span>:newName } = { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;&#x5F20;&#x4E09;&apos;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">13</span> }
<span class="hljs-built_in">console</span>.log(newName)  <span class="hljs-comment">// &#x5F20;&#x4E09;</span>
</code></pre>
<h3 id="21&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x9ED8;&#x8BA4;&#x503C;"><a name="21&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x9ED8;&#x8BA4;&#x503C;" class="anchor-navigation-ex-anchor" href="#21&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x9ED8;&#x8BA4;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.5. 21.&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x9ED8;&#x8BA4;&#x503C;</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> { dec=<span class="hljs-string">&apos;&#x8FD9;&#x662F;&#x9ED8;&#x8BA4;dec&#x503C;&apos;</span> } = { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;&#x5F20;&#x4E09;&apos;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">13</span> }
<span class="hljs-built_in">console</span>.log(dec) <span class="hljs-comment">//&#x8FD9;&#x662F;&#x9ED8;&#x8BA4;dec&#x503C;</span>
</code></pre>
<h3 id="22&#x62E6;&#x622A;&#x5BF9;&#x8C61;"><a name="22&#x62E6;&#x622A;&#x5BF9;&#x8C61;" class="anchor-navigation-ex-anchor" href="#22&#x62E6;&#x622A;&#x5BF9;&#x8C61;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.6. 22.&#x62E6;&#x622A;&#x5BF9;&#x8C61;</h3>
<p>&#x5229;&#x7528;Object.defineProperty&#x62E6;&#x622A;&#x5BF9;&#x8C61;
&#x65E0;&#x6CD5;&#x62E6;&#x622A;&#x6570;&#x7EC4;&#x7684;&#x503C;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> obj = { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;&apos;</span>, <span class="hljs-attr">age</span>: <span class="hljs-string">&apos;&apos;</span>, <span class="hljs-attr">sex</span>: <span class="hljs-string">&apos;&apos;</span> },
  defaultName = [<span class="hljs-string">&quot;&#x8FD9;&#x662F;&#x59D3;&#x540D;&#x9ED8;&#x8BA4;&#x503C;1&quot;</span>, <span class="hljs-string">&quot;&#x8FD9;&#x662F;&#x5E74;&#x9F84;&#x9ED8;&#x8BA4;&#x503C;1&quot;</span>, <span class="hljs-string">&quot;&#x8FD9;&#x662F;&#x6027;&#x522B;&#x9ED8;&#x8BA4;&#x503C;1&quot;</span>];
<span class="hljs-built_in">Object</span>.keys(obj).forEach(<span class="hljs-function"><span class="hljs-params">key</span> =&gt;</span> {
  <span class="hljs-built_in">Object</span>.defineProperty(obj, key, { <span class="hljs-comment">// &#x62E6;&#x622A;&#x6574;&#x4E2A;object &#x5BF9;&#x8C61;&#xFF0C;&#x5E76;&#x901A;&#x8FC7;get&#x83B7;&#x53D6;&#x503C;&#xFF0C;set&#x8BBE;&#x7F6E;&#x503C;&#xFF0C;vue 2.x&#x7684;&#x6838;&#x5FC3;&#x5C31;&#x662F;&#x8FD9;&#x4E2A;&#x6765;&#x76D1;&#x542C;</span>
    get() {
      <span class="hljs-keyword">return</span> defaultName;
    },
    set(value) {
      defaultName = value;
    }
  });
});

<span class="hljs-built_in">console</span>.log(obj.name); <span class="hljs-comment">// [ &apos;&#x8FD9;&#x662F;&#x59D3;&#x540D;&#x9ED8;&#x8BA4;&#x503C;1&apos;, &apos;&#x8FD9;&#x662F;&#x5E74;&#x9F84;&#x9ED8;&#x8BA4;&#x503C;1&apos;, &apos;&#x8FD9;&#x662F;&#x6027;&#x522B;&#x9ED8;&#x8BA4;&#x503C;1&apos; ]</span>
<span class="hljs-built_in">console</span>.log(obj.age); <span class="hljs-comment">// [ &apos;&#x8FD9;&#x662F;&#x59D3;&#x540D;&#x9ED8;&#x8BA4;&#x503C;1&apos;, &apos;&#x8FD9;&#x662F;&#x5E74;&#x9F84;&#x9ED8;&#x8BA4;&#x503C;1&apos;, &apos;&#x8FD9;&#x662F;&#x6027;&#x522B;&#x9ED8;&#x8BA4;&#x503C;1&apos; ]</span>
<span class="hljs-built_in">console</span>.log(obj.sex); <span class="hljs-comment">// [ &apos;&#x8FD9;&#x662F;&#x59D3;&#x540D;&#x9ED8;&#x8BA4;&#x503C;1&apos;, &apos;&#x8FD9;&#x662F;&#x5E74;&#x9F84;&#x9ED8;&#x8BA4;&#x503C;1&apos;, &apos;&#x8FD9;&#x662F;&#x6027;&#x522B;&#x9ED8;&#x8BA4;&#x503C;1&apos; ]</span>
obj.name = <span class="hljs-string">&quot;&#x8FD9;&#x662F;&#x6539;&#x53D8;&#x503C;1&quot;</span>;
<span class="hljs-built_in">console</span>.log(obj.name); <span class="hljs-comment">// &#x8FD9;&#x662F;&#x6539;&#x53D8;&#x503C;1</span>
<span class="hljs-built_in">console</span>.log(obj.age);  <span class="hljs-comment">// &#x8FD9;&#x662F;&#x6539;&#x53D8;&#x503C;1</span>
<span class="hljs-built_in">console</span>.log(obj.sex); <span class="hljs-comment">// &#x8FD9;&#x662F;&#x6539;&#x53D8;&#x503C;1</span>

<span class="hljs-keyword">let</span> objOne = {}, defaultNameOne = <span class="hljs-string">&quot;&#x8FD9;&#x662F;&#x9ED8;&#x8BA4;&#x503C;2&quot;</span>;
<span class="hljs-built_in">Object</span>.defineProperty(obj, <span class="hljs-string">&apos;name&apos;</span>, {
  get() {
    <span class="hljs-keyword">return</span> defaultNameOne;
  },
  set(value) {
    defaultNameOne = value;
  }
});
<span class="hljs-built_in">console</span>.log(objOne.name); <span class="hljs-comment">// undefined</span>
objOne.name = <span class="hljs-string">&quot;&#x8FD9;&#x662F;&#x6539;&#x53D8;&#x503C;2&quot;</span>;
<span class="hljs-built_in">console</span>.log(objOne.name); <span class="hljs-comment">// &#x8FD9;&#x662F;&#x6539;&#x53D8;&#x503C;2</span>
</code></pre>
<p>&#x5229;&#x7528;proxy&#x62E6;&#x622A;&#x5BF9;&#x8C61;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> obj = { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;&apos;</span>, <span class="hljs-attr">age</span>: <span class="hljs-string">&apos;&apos;</span>, <span class="hljs-attr">sex</span>: <span class="hljs-string">&apos;&apos;</span> }
<span class="hljs-keyword">let</span> handler = {
  get(target, key, receiver) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;get&quot;</span>, key); 
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Reflect</span>.get(target, key, receiver);
  },
  set(target, key, value, receiver) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;set&quot;</span>, key, value); <span class="hljs-comment">// set name &#x674E;&#x56DB;  // set age 24</span>
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Reflect</span>.set(target, key, value, receiver);
  }
};
<span class="hljs-keyword">let</span> proxy = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Proxy</span>(obj, handler);
proxy.name = <span class="hljs-string">&quot;&#x674E;&#x56DB;&quot;</span>;
proxy.age = <span class="hljs-number">24</span>;
</code></pre>
<p>defineProterty&#x548C;proxy&#x7684;&#x5BF9;&#x6BD4;&#xFF1A;
1.defineProterty&#x662F;es5&#x7684;&#x6807;&#x51C6;,proxy&#x662F;es6&#x7684;&#x6807;&#x51C6;;
2.proxy&#x53EF;&#x4EE5;&#x76D1;&#x542C;&#x5230;&#x6570;&#x7EC4;&#x7D22;&#x5F15;&#x8D4B;&#x503C;,&#x6539;&#x53D8;&#x6570;&#x7EC4;&#x957F;&#x5EA6;&#x7684;&#x53D8;&#x5316;;
3.proxy&#x662F;&#x76D1;&#x542C;&#x5BF9;&#x8C61;,&#x4E0D;&#x7528;&#x6DF1;&#x5C42;&#x904D;&#x5386;,defineProterty&#x662F;&#x76D1;&#x542C;&#x5C5E;&#x6027;;
4.&#x5229;&#x7528;defineProterty&#x5B9E;&#x73B0;&#x53CC;&#x5411;&#x6570;&#x636E;&#x7ED1;&#x5B9A;(vue2.x&#x91C7;&#x7528;&#x7684;&#x6838;&#x5FC3;)</p>
<h3 id="23&#x5BF9;&#x8C61;&#x6DF1;&#x5EA6;&#x62F7;&#x8D1D;"><a name="23&#x5BF9;&#x8C61;&#x6DF1;&#x5EA6;&#x62F7;&#x8D1D;" class="anchor-navigation-ex-anchor" href="#23&#x5BF9;&#x8C61;&#x6DF1;&#x5EA6;&#x62F7;&#x8D1D;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.7. 23.&#x5BF9;&#x8C61;&#x6DF1;&#x5EA6;&#x62F7;&#x8D1D;</h3>
<p>JSON.stringify&#x6DF1;&#x5EA6;&#x514B;&#x9686;&#x5BF9;&#x8C61;;
1.&#x65E0;&#x6CD5;&#x5BF9;&#x51FD;&#x6570; &#x3001;RegExp&#x7B49;&#x7279;&#x6B8A;&#x5BF9;&#x8C61;&#x7684;&#x514B;&#x9686;;
2.&#x4F1A;&#x629B;&#x5F03;&#x5BF9;&#x8C61;&#x7684;constructor,&#x6240;&#x6709;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x4F1A;&#x6307;&#x5411;Object;
3.&#x5BF9;&#x8C61;&#x6709;&#x5FAA;&#x73AF;&#x5F15;&#x7528;,&#x4F1A;&#x62A5;&#x9519;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> objDeepClone = <span class="hljs-function"><span class="hljs-params">obj</span> =&gt;</span> {
  <span class="hljs-keyword">return</span> clone(obj)
}

<span class="hljs-keyword">const</span> isType = <span class="hljs-function">(<span class="hljs-params">obj, type</span>) =&gt;</span> {
  <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> obj !== <span class="hljs-string">&apos;object&apos;</span>) <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
  <span class="hljs-comment">// &#x5224;&#x65AD;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x7684;&#x7ECF;&#x5178;&#x65B9;&#x6CD5;&#xFF1A;</span>
  <span class="hljs-keyword">const</span> typeString = <span class="hljs-built_in">Object</span>.prototype.toString.call(obj);
  <span class="hljs-keyword">let</span> flag;
  <span class="hljs-keyword">switch</span> (type) {
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;Array&apos;</span>:
      flag = typeString === <span class="hljs-string">&apos;[object Array]&apos;</span>;
      <span class="hljs-keyword">break</span>;
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;Date&apos;</span>:
      flag = typeString === <span class="hljs-string">&apos;[object Date]&apos;</span>;
      <span class="hljs-keyword">break</span>;
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;RegExp&apos;</span>:
      flag = typeString === <span class="hljs-string">&apos;[object RegExp]&apos;</span>;
      <span class="hljs-keyword">break</span>;
    <span class="hljs-keyword">default</span>:
      flag = <span class="hljs-literal">false</span>;
  }
  <span class="hljs-keyword">return</span> flag;
};

<span class="hljs-comment">/**
* deep clone
* @param  {[type]} parent object &#x9700;&#x8981;&#x8FDB;&#x884C;&#x514B;&#x9686;&#x7684;&#x5BF9;&#x8C61;
* @return {[type]}        &#x6DF1;&#x514B;&#x9686;&#x540E;&#x7684;&#x5BF9;&#x8C61;
*/</span>
<span class="hljs-keyword">const</span> clone = <span class="hljs-function"><span class="hljs-params">parent</span> =&gt;</span> {
  <span class="hljs-comment">// &#x7EF4;&#x62A4;&#x4E24;&#x4E2A;&#x50A8;&#x5B58;&#x5FAA;&#x73AF;&#x5F15;&#x7528;&#x7684;&#x6570;&#x7EC4;</span>
  <span class="hljs-keyword">const</span> parents = []
  <span class="hljs-keyword">const</span> children = []

  <span class="hljs-keyword">const</span> _clone = <span class="hljs-function"><span class="hljs-params">parent</span> =&gt;</span> {
    <span class="hljs-keyword">if</span> (parent === <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> <span class="hljs-literal">null</span>
    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> parent !== <span class="hljs-string">&apos;object&apos;</span>) <span class="hljs-keyword">return</span> parent

    <span class="hljs-keyword">let</span> child, proto

    <span class="hljs-keyword">if</span> (isType(parent, <span class="hljs-string">&apos;Array&apos;</span>)) {
      <span class="hljs-comment">// &#x5BF9;&#x6570;&#x7EC4;&#x505A;&#x7279;&#x6B8A;&#x5904;&#x7406;</span>
      child = []
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (isType(parent, <span class="hljs-string">&apos;RegExp&apos;</span>)) {
      <span class="hljs-comment">// &#x5BF9;&#x6B63;&#x5219;&#x5BF9;&#x8C61;&#x505A;&#x7279;&#x6B8A;&#x5904;&#x7406;</span>
      child = <span class="hljs-keyword">new</span> <span class="hljs-built_in">RegExp</span>(parent.source, getRegExp(parent))
      <span class="hljs-keyword">if</span> (parent.lastIndex) child.lastIndex = parent.lastIndex
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (isType(parent, <span class="hljs-string">&apos;Date&apos;</span>)) {
      <span class="hljs-comment">// &#x5BF9;Date&#x5BF9;&#x8C61;&#x505A;&#x7279;&#x6B8A;&#x5904;&#x7406;</span>
      child = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(parent.getTime())
    } <span class="hljs-keyword">else</span> {
      <span class="hljs-comment">// &#x5904;&#x7406;&#x5BF9;&#x8C61;&#x539F;&#x578B;</span>
      proto = <span class="hljs-built_in">Object</span>.getPrototypeOf(parent)
      <span class="hljs-comment">// &#x5229;&#x7528;Object.create&#x5207;&#x65AD;&#x539F;&#x578B;&#x94FE;</span>
      child = <span class="hljs-built_in">Object</span>.create(proto)
    }

    <span class="hljs-comment">// &#x5904;&#x7406;&#x5FAA;&#x73AF;&#x5F15;&#x7528;</span>
    <span class="hljs-keyword">const</span> index = parents.indexOf(parent)

    <span class="hljs-keyword">if</span> (index !== <span class="hljs-number">-1</span>) {
      <span class="hljs-comment">// &#x5982;&#x679C;&#x7236;&#x6570;&#x7EC4;&#x5B58;&#x5728;&#x672C;&#x5BF9;&#x8C61;,&#x8BF4;&#x660E;&#x4E4B;&#x524D;&#x5DF2;&#x7ECF;&#x88AB;&#x5F15;&#x7528;&#x8FC7;,&#x76F4;&#x63A5;&#x8FD4;&#x56DE;&#x6B64;&#x5BF9;&#x8C61;</span>
      <span class="hljs-keyword">return</span> children[index]
    }
    parents.push(parent)
    children.push(child)

    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">const</span> i <span class="hljs-keyword">in</span> parent) {
      <span class="hljs-comment">// &#x9012;&#x5F52;</span>
      child[i] = _clone(parent[i])
    }

    <span class="hljs-keyword">return</span> child
  }
  <span class="hljs-keyword">return</span> _clone(parent)
}

<span class="hljs-built_in">console</span>.log(objDeepClone({ 
  <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;&#x5F20;&#x4E09;&apos;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">23</span>, 
  <span class="hljs-attr">obj</span>: { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;&#x674E;&#x56DB;&apos;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">46</span>},
  <span class="hljs-attr">arr</span>:[<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>]
})) <span class="hljs-comment">// { name: &apos;&#x5F20;&#x4E09;&apos;, age: 23, obj: { name: &apos;&#x674E;&#x56DB;&apos;, age: 46 }, arr: [ 1, 2, 3 ] }</span>
</code></pre>
<p>&#x5BF9;&#x8C61;&#x6DF1;&#x5EA6;&#x514B;&#x9686;&#x5B9E;&#x9645;&#x4E0A;&#x5C31;&#x662F;&#x8981;&#x517C;&#x5BB9;Array&#xFF0C;RegExp&#xFF0C;Date&#xFF0C;Function&#x7C7B;&#x578B;&#xFF1B;
&#x514B;&#x9686;&#x51FD;&#x6570;&#x53EF;&#x4EE5;&#x7528;&#x6B63;&#x5219;&#x53D6;&#x51FA;&#x51FD;&#x6570;&#x4F53;&#x548C;&#x53C2;&#x6570;&#xFF0C;&#x518D;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x5C06;&#x53D6;&#x51FA;&#x6765;&#x7684;&#x503C;&#x8D4B;&#x503C;&#x8FDB;&#x53BB;
&#x8BE6;&#x7EC6;<a href="https://juejin.im/post/5d6aa4f96fb9a06b112ad5b1#heading-12" target="_blank">&#x8BF7;&#x6233;&#x5BF9;&#x8C61;&#x6DF1;&#x5EA6;&#x62F7;&#x8D1D;</a></p>
<h3 id="24&#x5BF9;&#x8C61;&#x662F;&#x5426;&#x76F8;&#x7B49;"><a name="24&#x5BF9;&#x8C61;&#x662F;&#x5426;&#x76F8;&#x7B49;" class="anchor-navigation-ex-anchor" href="#24&#x5BF9;&#x8C61;&#x662F;&#x5426;&#x76F8;&#x7B49;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.8. 24.&#x5BF9;&#x8C61;&#x662F;&#x5426;&#x76F8;&#x7B49;</h3>
<p>&#x5982;&#x679C;&#x7528;JSON.stringify&#x8F6C;&#x5316;&#x5C5E;&#x6027;&#x987A;&#x5E8F;&#x4E0D;&#x540C;&#xFF0C;&#x4E5F;&#x4E0D;&#x76F8;&#x7B49;&#xFF1B;
&#x800C;&#x4E14;&#x4E0D;&#x652F;&#x6301;&#x65E0;&#x6CD5;&#x5BF9;&#x51FD;&#x6570; &#x3001;RegExp&#x7B49;&#x7279;&#x6B8A;&#x5BF9;&#x8C61;&#x7684;&#x514B;&#x9686;</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">deepCompare</span>(<span class="hljs-params">x, y</span>) </span>{
  <span class="hljs-keyword">var</span> i, l, leftChain, rightChain;

  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">compare2Objects</span>(<span class="hljs-params">x, y</span>) </span>{
    <span class="hljs-keyword">var</span> p;

    <span class="hljs-comment">// remember that NaN === NaN returns false</span>
    <span class="hljs-comment">// and isNaN(undefined) returns true</span>
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">isNaN</span>(x) &amp;&amp; <span class="hljs-built_in">isNaN</span>(y) &amp;&amp; <span class="hljs-keyword">typeof</span> x === <span class="hljs-string">&apos;number&apos;</span> &amp;&amp; <span class="hljs-keyword">typeof</span> y === <span class="hljs-string">&apos;number&apos;</span>) {
      <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
    }

    <span class="hljs-comment">// Compare primitives and functions.     </span>
    <span class="hljs-comment">// Check if both arguments link to the same object.</span>
    <span class="hljs-comment">// Especially useful on the step where we compare prototypes</span>
    <span class="hljs-keyword">if</span> (x === y) {
      <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
    }

    <span class="hljs-comment">// Works in case when functions are created in constructor.</span>
    <span class="hljs-comment">// Comparing dates is a common scenario. Another built-ins?</span>
    <span class="hljs-comment">// We can even handle functions passed across iframes</span>
    <span class="hljs-keyword">if</span> ((<span class="hljs-keyword">typeof</span> x === <span class="hljs-string">&apos;function&apos;</span> &amp;&amp; <span class="hljs-keyword">typeof</span> y === <span class="hljs-string">&apos;function&apos;</span>) ||
      (x <span class="hljs-keyword">instanceof</span> <span class="hljs-built_in">Date</span> &amp;&amp; y <span class="hljs-keyword">instanceof</span> <span class="hljs-built_in">Date</span>) ||
      (x <span class="hljs-keyword">instanceof</span> <span class="hljs-built_in">RegExp</span> &amp;&amp; y <span class="hljs-keyword">instanceof</span> <span class="hljs-built_in">RegExp</span>) ||
      (x <span class="hljs-keyword">instanceof</span> <span class="hljs-built_in">String</span> &amp;&amp; y <span class="hljs-keyword">instanceof</span> <span class="hljs-built_in">String</span>) ||
      (x <span class="hljs-keyword">instanceof</span> <span class="hljs-built_in">Number</span> &amp;&amp; y <span class="hljs-keyword">instanceof</span> <span class="hljs-built_in">Number</span>)) {
      <span class="hljs-keyword">return</span> x.toString() === y.toString();
    }

    <span class="hljs-comment">// At last checking prototypes as good as we can</span>
    <span class="hljs-keyword">if</span> (!(x <span class="hljs-keyword">instanceof</span> <span class="hljs-built_in">Object</span> &amp;&amp; y <span class="hljs-keyword">instanceof</span> <span class="hljs-built_in">Object</span>)) {
      <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
    }

    <span class="hljs-keyword">if</span> (x.isPrototypeOf(y) || y.isPrototypeOf(x)) {
      <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
    }

    <span class="hljs-keyword">if</span> (x.constructor !== y.constructor) {
      <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
    }

    <span class="hljs-keyword">if</span> (x.prototype !== y.prototype) {
      <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
    }

    <span class="hljs-comment">// Check for infinitive linking loops</span>
    <span class="hljs-keyword">if</span> (leftChain.indexOf(x) &gt; <span class="hljs-number">-1</span> || rightChain.indexOf(y) &gt; <span class="hljs-number">-1</span>) {
      <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
    }

    <span class="hljs-comment">// Quick checking of one object being a subset of another.</span>
    <span class="hljs-comment">// todo: cache the structure of arguments[0] for performance</span>
    <span class="hljs-keyword">for</span> (p <span class="hljs-keyword">in</span> y) {
      <span class="hljs-keyword">if</span> (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {
        <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
      } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> y[p] !== <span class="hljs-keyword">typeof</span> x[p]) {
        <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
      }
    }

    <span class="hljs-keyword">for</span> (p <span class="hljs-keyword">in</span> x) {
      <span class="hljs-keyword">if</span> (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {
        <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
      } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> y[p] !== <span class="hljs-keyword">typeof</span> x[p]) {
        <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
      }

      <span class="hljs-keyword">switch</span> (<span class="hljs-keyword">typeof</span> (x[p])) {
        <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;object&apos;</span>:
        <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;function&apos;</span>:

          leftChain.push(x);
          rightChain.push(y);

          <span class="hljs-keyword">if</span> (!compare2Objects(x[p], y[p])) {
            <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
          }

          leftChain.pop();
          rightChain.pop();
          <span class="hljs-keyword">break</span>;

        <span class="hljs-keyword">default</span>:
          <span class="hljs-keyword">if</span> (x[p] !== y[p]) {
            <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
          }
          <span class="hljs-keyword">break</span>;
      }
    }

    <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
  }

  <span class="hljs-keyword">if</span> (<span class="hljs-built_in">arguments</span>.length &lt; <span class="hljs-number">1</span>) {
    <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>; 
  }

  <span class="hljs-keyword">for</span> (i = <span class="hljs-number">1</span>, l = <span class="hljs-built_in">arguments</span>.length; i &lt; l; i++) {

    leftChain = []; <span class="hljs-comment">//Todo: this can be cached</span>
    rightChain = [];

    <span class="hljs-keyword">if</span> (!compare2Objects(<span class="hljs-built_in">arguments</span>[<span class="hljs-number">0</span>], <span class="hljs-built_in">arguments</span>[i])) {
      <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
    }
  }

  <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
}

<span class="hljs-keyword">const</span> obj1 = { 
  <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;&#x5F20;&#x4E09;&apos;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">23</span>, 
  <span class="hljs-attr">obj</span>: { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;&#x674E;&#x56DB;&apos;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">46</span> }, 
  <span class="hljs-attr">arr</span>: [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>],
  <span class="hljs-attr">date</span>:<span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">23</span>),
  <span class="hljs-attr">reg</span>: <span class="hljs-keyword">new</span> <span class="hljs-built_in">RegExp</span>(<span class="hljs-string">&apos;abc&apos;</span>),
  <span class="hljs-attr">fun</span>: <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>{}
 }
<span class="hljs-keyword">const</span> obj2 = { 
  <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;&#x5F20;&#x4E09;&apos;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">23</span>, 
  <span class="hljs-attr">obj</span>: { <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;&#x674E;&#x56DB;&apos;</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">46</span> }, 
  <span class="hljs-attr">arr</span>: [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>],
  <span class="hljs-attr">date</span>: <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">23</span>),
  <span class="hljs-attr">reg</span>: <span class="hljs-keyword">new</span> <span class="hljs-built_in">RegExp</span>(<span class="hljs-string">&apos;abc&apos;</span>),
  <span class="hljs-attr">fun</span>: <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>{}
 }

<span class="hljs-built_in">console</span>.log(deepCompare(obj1,obj2)) <span class="hljs-comment">// true</span>
</code></pre>
<p>&#x5224;&#x65AD;&#x5BF9;&#x8C61;&#x662F;&#x5426;&#x76F8;&#x7B49;&#xFF0C;&#x5B9E;&#x9645;&#x4E0A;&#x5C31;&#x662F;&#x8981;&#x5904;&#x7406;Array&#xFF0C;Date&#xFF0C;RegExp&#xFF0C;Object&#xFF0C;Function&#x7684;&#x7279;&#x6B8A;&#x7C7B;&#x578B;&#x662F;&#x5426;&#x76F8;&#x7B49;</p>
<h3 id="25&#x5BF9;&#x8C61;&#x8F6C;&#x5316;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;"><a name="25&#x5BF9;&#x8C61;&#x8F6C;&#x5316;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;" class="anchor-navigation-ex-anchor" href="#25&#x5BF9;&#x8C61;&#x8F6C;&#x5316;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.9. 25.&#x5BF9;&#x8C61;&#x8F6C;&#x5316;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;</h3>
<p>&#x901A;&#x8FC7;&#x5B57;&#x7B26;&#x4E32;+Object &#x7684;&#x65B9;&#x5F0F;&#x6765;&#x8F6C;&#x5316;&#x5BF9;&#x8C61;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;(&#x5B9E;&#x9645;&#x4E0A;&#x662F;&#x8C03;&#x7528; .toString() &#x65B9;&#x6CD5;)</p>
<pre><code class="lang-javascript"><span class="hljs-string">&apos;the Math object:&apos;</span> + <span class="hljs-built_in">Math</span>.ceil(<span class="hljs-number">3.4</span>)                <span class="hljs-comment">// &quot;the Math object:4&quot;</span>
<span class="hljs-string">&apos;the JSON object:&apos;</span> + {<span class="hljs-attr">name</span>:<span class="hljs-string">&apos;&#x66F9;&#x64CD;&apos;</span>}              <span class="hljs-comment">// &quot;the JSON object:[object Object]&quot;</span>
</code></pre>
<p>&#x8986;&#x76D6;&#x5BF9;&#x8C61;&#x7684;toString&#x548C;valueOf&#x65B9;&#x6CD5;&#x6765;&#x81EA;&#x5B9A;&#x4E49;&#x5BF9;&#x8C61;&#x7684;&#x7C7B;&#x578B;&#x8F6C;&#x6362;</p>
<pre><code class="lang-javascript"><span class="hljs-number">2</span>  * { <span class="hljs-attr">valueOf</span>: <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span><span class="hljs-string">&apos;4&apos;</span> }                <span class="hljs-comment">// 8</span>
<span class="hljs-string">&apos;J&apos;</span> + { <span class="hljs-attr">toString</span>: <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span><span class="hljs-string">&apos;ava&apos;</span> }                <span class="hljs-comment">// &quot;Java&quot;</span>
</code></pre>
<p>&#x5F53;+&#x7528;&#x5728;&#x8FDE;&#x63A5;&#x5B57;&#x7B26;&#x4E32;&#x65F6;&#xFF0C;&#x5F53;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x65E2;&#x6709;toString&#x65B9;&#x6CD5;&#x53C8;&#x6709;valueOf&#x65B9;&#x6CD5;&#x65F6;&#x5019;&#xFF0C;JS&#x901A;&#x8FC7;&#x76F2;&#x76EE;&#x4F7F;&#x7528;valueOf&#x65B9;&#x6CD5;&#x6765;&#x89E3;&#x51B3;&#x8FD9;&#x79CD;&#x542B;&#x7CCA;;
&#x5BF9;&#x8C61;&#x901A;&#x8FC7;valueOf&#x65B9;&#x6CD5;&#x5F3A;&#x5236;&#x8F6C;&#x6362;&#x4E3A;&#x6570;&#x5B57;&#xFF0C;&#x901A;&#x8FC7;toString&#x65B9;&#x6CD5;&#x5F3A;&#x5236;&#x8F6C;&#x6362;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;</p>
<pre><code class="lang-javascript"><span class="hljs-string">&apos;&apos;</span> + {<span class="hljs-attr">toString</span>:<span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span><span class="hljs-string">&apos;S&apos;</span>,<span class="hljs-attr">valueOf</span>:<span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span><span class="hljs-string">&apos;J&apos;</span>} <span class="hljs-comment">//J</span>
</code></pre>
<h2 id="function"><a name="function" class="anchor-navigation-ex-anchor" href="#function"><i class="fa fa-link" aria-hidden="true"></i></a>1.5. Function</h2>
<h3 id="26&#x51FD;&#x6570;&#x9690;&#x5F0F;&#x8FD4;&#x56DE;&#x503C;"><a name="26&#x51FD;&#x6570;&#x9690;&#x5F0F;&#x8FD4;&#x56DE;&#x503C;" class="anchor-navigation-ex-anchor" href="#26&#x51FD;&#x6570;&#x9690;&#x5F0F;&#x8FD4;&#x56DE;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.5.1. 26.&#x51FD;&#x6570;&#x9690;&#x5F0F;&#x8FD4;&#x56DE;&#x503C;</h3>
<pre><code class="lang-javascript">(<span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span><span class="hljs-number">3</span>)()  <span class="hljs-comment">//3</span>
(<span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>(
   <span class="hljs-number">3</span>
))()
</code></pre>
<p>&#x51FD;&#x6570;&#x7701;&#x7565;&#x5927;&#x62EC;&#x53F7;&#xFF0C;&#x6216;&#x8005;&#x5C06;&#x5927;&#x62EC;&#x53F7;&#x6539;&#x6210;&#x5C0F;&#x62EC;&#x53F7;&#x53EF;&#x4EE5;&#x786E;&#x4FDD;&#x4EE3;&#x7801;&#x4EE5;&#x5355;&#x4E2A;&#x8BED;&#x53E5;&#x7684;&#x5F62;&#x5F0F;&#x8FDB;&#x884C;&#x6C42;&#x503C;</p>
<h3 id="27&#x51FD;&#x6570;&#x81EA;&#x6267;&#x884C;"><a name="27&#x51FD;&#x6570;&#x81EA;&#x6267;&#x884C;" class="anchor-navigation-ex-anchor" href="#27&#x51FD;&#x6570;&#x81EA;&#x6267;&#x884C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.5.2. 27.&#x51FD;&#x6570;&#x81EA;&#x6267;&#x884C;</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> Func = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}(); <span class="hljs-comment">// &#x5E38;&#x7528;</span>

(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{})(); <span class="hljs-comment">// &#x5E38;&#x7528;</span>
(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}()); <span class="hljs-comment">// &#x5E38;&#x7528;</span>
[<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}()];

<span class="hljs-keyword">new</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{};
<span class="hljs-keyword">new</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
<span class="hljs-keyword">void</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
<span class="hljs-keyword">typeof</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
<span class="hljs-keyword">delete</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();

+ <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
- <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
~ <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
! <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
</code></pre>
<h3 id="28&#x51FD;&#x6570;&#x5F02;&#x6B65;&#x6267;&#x884C;"><a name="28&#x51FD;&#x6570;&#x5F02;&#x6B65;&#x6267;&#x884C;" class="anchor-navigation-ex-anchor" href="#28&#x51FD;&#x6570;&#x5F02;&#x6B65;&#x6267;&#x884C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.5.3. 28.&#x51FD;&#x6570;&#x5F02;&#x6B65;&#x6267;&#x884C;</h3>
<p>Promise</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">Promise</span>.reject(<span class="hljs-string">&apos;&#x8FD9;&#x662F;&#x7B2C;&#x4E8C;&#x4E2A; reject &#x503C;&apos;</span>).then(<span class="hljs-function">(<span class="hljs-params">data</span>)=&gt;</span>{
  <span class="hljs-built_in">console</span>.log(data)
}).catch(<span class="hljs-function"><span class="hljs-params">data</span>=&gt;</span>{
  <span class="hljs-built_in">console</span>.log(data) <span class="hljs-comment">//&#x8FD9;&#x662F;&#x7B2C;&#x4E8C;&#x4E2A; reject &#x503C;</span>
})
</code></pre>
<p>Generator</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span>* <span class="hljs-title">gen</span>(<span class="hljs-params">x</span>) </span>{
  <span class="hljs-keyword">const</span> y = <span class="hljs-keyword">yield</span> x + <span class="hljs-number">6</span>;
  <span class="hljs-keyword">return</span> y;
}

<span class="hljs-comment">// yield &#x5982;&#x679C;&#x7528;&#x5728;&#x53E6;&#x5916;&#x4E00;&#x4E2A;&#x8868;&#x8FBE;&#x5F0F;&#x4E2D;,&#x8981;&#x653E;&#x5728;()&#x91CC;&#x9762;</span>
<span class="hljs-comment">// &#x50CF;&#x4E0A;&#x9762;&#x5982;&#x679C;&#x662F;&#x5728;=&#x53F3;&#x8FB9;&#x5C31;&#x4E0D;&#x7528;&#x52A0;()</span>
<span class="hljs-function"><span class="hljs-keyword">function</span>* <span class="hljs-title">genOne</span>(<span class="hljs-params">x</span>) </span>{
  <span class="hljs-keyword">const</span> y = <span class="hljs-string">`&#x8FD9;&#x662F;&#x7B2C;&#x4E00;&#x4E2A; yield &#x6267;&#x884C;:<span class="hljs-subst">${<span class="hljs-keyword">yield</span> x + <span class="hljs-number">1</span>}</span>`</span>;
  <span class="hljs-keyword">return</span> y;
}

<span class="hljs-keyword">const</span> g = gen(<span class="hljs-number">1</span>);
<span class="hljs-comment">//&#x6267;&#x884C; Generator &#x4F1A;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;Object,&#x800C;&#x4E0D;&#x662F;&#x50CF;&#x666E;&#x901A;&#x51FD;&#x6570;&#x8FD4;&#x56DE;return &#x540E;&#x9762;&#x7684;&#x503C;</span>
g.next() <span class="hljs-comment">// { value: 7, done: false }</span>
<span class="hljs-comment">//&#x8C03;&#x7528;&#x6307;&#x9488;&#x7684; next &#x65B9;&#x6CD5;,&#x4F1A;&#x4ECE;&#x51FD;&#x6570;&#x7684;&#x5934;&#x90E8;&#x6216;&#x4E0A;&#x4E00;&#x6B21;&#x505C;&#x4E0B;&#x6765;&#x7684;&#x5730;&#x65B9;&#x5F00;&#x59CB;&#x6267;&#x884C;&#xFF0C;&#x76F4;&#x5230;&#x9047;&#x5230;&#x4E0B;&#x4E00;&#x4E2A; yield &#x8868;&#x8FBE;&#x5F0F;&#x6216;return&#x8BED;&#x53E5;&#x6682;&#x505C;,&#x4E5F;&#x5C31;&#x662F;&#x6267;&#x884C;yield &#x8FD9;&#x4E00;&#x884C;</span>
<span class="hljs-comment">// &#x6267;&#x884C;&#x5B8C;&#x6210;&#x4F1A;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A; Object,</span>
<span class="hljs-comment">// value &#x5C31;&#x662F;&#x6267;&#x884C; yield &#x540E;&#x9762;&#x7684;&#x503C;,done &#x8868;&#x793A;&#x51FD;&#x6570;&#x662F;&#x5426;&#x6267;&#x884C;&#x5B8C;&#x6BD5;</span>
g.next() <span class="hljs-comment">// { value: undefined, done: true }</span>
<span class="hljs-comment">// &#x56E0;&#x4E3A;&#x6700;&#x540E;&#x4E00;&#x884C; return y &#x88AB;&#x6267;&#x884C;&#x5B8C;&#x6210;,&#x6240;&#x4EE5;done &#x4E3A; true</span>
</code></pre>
<p>Async/Await</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getSomething</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;something&quot;</span>;
}
<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">testAsync</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Promise</span>.resolve(<span class="hljs-string">&quot;hello async&quot;</span>);
}
<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">test</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">const</span> v1 = <span class="hljs-keyword">await</span> getSomething();
    <span class="hljs-keyword">const</span> v2 = <span class="hljs-keyword">await</span> testAsync();
    <span class="hljs-built_in">console</span>.log(v1, v2); <span class="hljs-comment">//something &#x548C; hello async</span>
}
test();
</code></pre>
<h2 id="string"><a name="string" class="anchor-navigation-ex-anchor" href="#string"><i class="fa fa-link" aria-hidden="true"></i></a>1.6. String</h2>
<h3 id="29&#x5B57;&#x7B26;&#x4E32;&#x7FFB;&#x8F6C;"><a name="29&#x5B57;&#x7B26;&#x4E32;&#x7FFB;&#x8F6C;" class="anchor-navigation-ex-anchor" href="#29&#x5B57;&#x7B26;&#x4E32;&#x7FFB;&#x8F6C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6.1. 29.&#x5B57;&#x7B26;&#x4E32;&#x7FFB;&#x8F6C;</h3>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">reverseStr</span>(<span class="hljs-params">str = <span class="hljs-string">&quot;&quot;</span></span>) </span>{
  <span class="hljs-keyword">return</span> str.split(<span class="hljs-string">&quot;&quot;</span>).reduceRight(<span class="hljs-function">(<span class="hljs-params">t, v</span>) =&gt;</span> t + v);
}

<span class="hljs-keyword">const</span> str = <span class="hljs-string">&quot;reduce123&quot;</span>;
<span class="hljs-built_in">console</span>.log(reverseStr(str)); <span class="hljs-comment">// &quot;321recuder&quot;</span>
</code></pre>
<h3 id="30url&#x53C2;&#x6570;&#x5E8F;&#x5217;&#x5316;"><a name="30url&#x53C2;&#x6570;&#x5E8F;&#x5217;&#x5316;" class="anchor-navigation-ex-anchor" href="#30url&#x53C2;&#x6570;&#x5E8F;&#x5217;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6.2. 30.url&#x53C2;&#x6570;&#x5E8F;&#x5217;&#x5316;</h3>
<p>&#x5C06;&#x5BF9;&#x8C61;&#x5E8F;&#x5217;&#x5316;&#x6210;url&#x53C2;&#x6570;&#x4F20;&#x9012;</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">stringifyUrl</span>(<span class="hljs-params">search = {}</span>) </span>{
  <span class="hljs-keyword">return</span> <span class="hljs-built_in">Object</span>.entries(search).reduce(
    <span class="hljs-function">(<span class="hljs-params">t, v</span>) =&gt;</span> <span class="hljs-string">`<span class="hljs-subst">${t}</span><span class="hljs-subst">${v[<span class="hljs-number">0</span>]}</span>=<span class="hljs-subst">${<span class="hljs-built_in">encodeURIComponent</span>(v[<span class="hljs-number">1</span>])}</span>&amp;`</span>,
    <span class="hljs-built_in">Object</span>.keys(search).length ? <span class="hljs-string">&quot;?&quot;</span> : <span class="hljs-string">&quot;&quot;</span>
  ).replace(<span class="hljs-regexp">/&amp;$/</span>, <span class="hljs-string">&quot;&quot;</span>);
}

<span class="hljs-built_in">console</span>.log(stringifyUrl({ <span class="hljs-attr">age</span>: <span class="hljs-number">27</span>, <span class="hljs-attr">name</span>: <span class="hljs-string">&quot;YZW&quot;</span> })); <span class="hljs-comment">// &quot;?age=27&amp;name=YZW&quot;</span>
</code></pre>
<h3 id="31url&#x53C2;&#x6570;&#x53CD;&#x5E8F;&#x5217;&#x5316;"><a name="31url&#x53C2;&#x6570;&#x53CD;&#x5E8F;&#x5217;&#x5316;" class="anchor-navigation-ex-anchor" href="#31url&#x53C2;&#x6570;&#x53CD;&#x5E8F;&#x5217;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6.3. 31.url&#x53C2;&#x6570;&#x53CD;&#x5E8F;&#x5217;&#x5316;</h3>
<p>&#x4E00;&#x822C;&#x4F1A;&#x901A;&#x8FC7;location.search&#x62FF;&#x5230;&#x8DEF;&#x7531;&#x4F20;&#x9012;&#x7684;&#x53C2;&#x6570;&#xFF0C;&#x5E76;&#x8FDB;&#x884C;&#x53CD;&#x5E8F;&#x5217;&#x5316;&#x5F97;&#x5230;&#x5BF9;&#x8C61;</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">parseUrlSearch</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> search = <span class="hljs-string">&apos;?age=25&amp;name=TYJ&apos;</span>
  <span class="hljs-keyword">return</span> search.replace(<span class="hljs-regexp">/(^\?)|(&amp;$)/g</span>, <span class="hljs-string">&quot;&quot;</span>).split(<span class="hljs-string">&quot;&amp;&quot;</span>).reduce(<span class="hljs-function">(<span class="hljs-params">t, v</span>) =&gt;</span> {
    <span class="hljs-keyword">const</span> [key, val] = v.split(<span class="hljs-string">&quot;=&quot;</span>);
    t[key] = <span class="hljs-built_in">decodeURIComponent</span>(val);
    <span class="hljs-keyword">return</span> t;
  }, {});
}

<span class="hljs-built_in">console</span>.log(parseUrlSearch()); <span class="hljs-comment">// { age: &quot;25&quot;, name: &quot;TYJ&quot; }</span>
</code></pre>
<h3 id="32&#x8F6C;&#x5316;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;"><a name="32&#x8F6C;&#x5316;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;" class="anchor-navigation-ex-anchor" href="#32&#x8F6C;&#x5316;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6.4. 32.&#x8F6C;&#x5316;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> val = <span class="hljs-number">1</span> + <span class="hljs-string">&quot;&quot;</span>; <span class="hljs-comment">// &#x901A;&#x8FC7;+ &apos;&apos;&#x7A7A;&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x5316;</span>
<span class="hljs-built_in">console</span>.log(val); <span class="hljs-comment">// &quot;1&quot;</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">typeof</span> val); <span class="hljs-comment">// &quot;string&quot;</span>

<span class="hljs-keyword">const</span> val1 = <span class="hljs-built_in">String</span>(<span class="hljs-number">1</span>);
<span class="hljs-built_in">console</span>.log(val1); <span class="hljs-comment">// &quot;1&quot;</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">typeof</span> val1); <span class="hljs-comment">// &quot;string&quot;</span>
</code></pre>
<h2 id="number"><a name="number" class="anchor-navigation-ex-anchor" href="#number"><i class="fa fa-link" aria-hidden="true"></i></a>1.7. Number</h2>
<h3 id="33&#x6570;&#x5B57;&#x5343;&#x5206;&#x4F4D;"><a name="33&#x6570;&#x5B57;&#x5343;&#x5206;&#x4F4D;" class="anchor-navigation-ex-anchor" href="#33&#x6570;&#x5B57;&#x5343;&#x5206;&#x4F4D;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7.1. 33.&#x6570;&#x5B57;&#x5343;&#x5206;&#x4F4D;</h3>
<p>&#x65B9;&#x6CD5;&#x4E00;&#xFF1A;</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">thousandNum</span>(<span class="hljs-params">num = <span class="hljs-number">0</span></span>) </span>{
  <span class="hljs-keyword">const</span> str = (+num).toString().split(<span class="hljs-string">&quot;.&quot;</span>);
  <span class="hljs-keyword">const</span> int = <span class="hljs-function"><span class="hljs-params">nums</span> =&gt;</span> nums.split(<span class="hljs-string">&quot;&quot;</span>).reverse().reduceRight(<span class="hljs-function">(<span class="hljs-params">t, v, i</span>) =&gt;</span> t + (i % <span class="hljs-number">3</span> ? v : <span class="hljs-string">`<span class="hljs-subst">${v}</span>,`</span>), <span class="hljs-string">&quot;&quot;</span>).replace(<span class="hljs-regexp">/^,|,$/g</span>, <span class="hljs-string">&quot;&quot;</span>);
  <span class="hljs-keyword">const</span> dec = <span class="hljs-function"><span class="hljs-params">nums</span> =&gt;</span> nums.split(<span class="hljs-string">&quot;&quot;</span>).reduce(<span class="hljs-function">(<span class="hljs-params">t, v, i</span>) =&gt;</span> t + ((i + <span class="hljs-number">1</span>) % <span class="hljs-number">3</span> ? v : <span class="hljs-string">`<span class="hljs-subst">${v}</span>,`</span>), <span class="hljs-string">&quot;&quot;</span>).replace(<span class="hljs-regexp">/^,|,$/g</span>, <span class="hljs-string">&quot;&quot;</span>);
  <span class="hljs-keyword">return</span> str.length &gt; <span class="hljs-number">1</span> ? <span class="hljs-string">`<span class="hljs-subst">${int(str[<span class="hljs-number">0</span>])}</span>.<span class="hljs-subst">${dec(str[<span class="hljs-number">1</span>])}</span>`</span> : int(str[<span class="hljs-number">0</span>]);
}

thousandNum(<span class="hljs-number">1234</span>); <span class="hljs-comment">// &quot;1,234&quot;</span>
thousandNum(<span class="hljs-number">1234.00</span>); <span class="hljs-comment">// &quot;1,234&quot;</span>
thousandNum(<span class="hljs-number">0.1234</span>); <span class="hljs-comment">// &quot;0.123,4&quot;</span>
<span class="hljs-built_in">console</span>.log(thousandNum(<span class="hljs-number">1234.5678</span>)); <span class="hljs-comment">// &quot;1,234.567,8&quot;</span>
</code></pre>
<p>&#x65B9;&#x6CD5;&#x4E8C;</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;1234567890&apos;</span>.replace(<span class="hljs-regexp">/\B(?=(\d{3})+(?!\d))/g</span>, <span class="hljs-string">&quot;,&quot;</span>))
<span class="hljs-built_in">console</span>.log((<span class="hljs-number">1234567890</span>).toLocaleString())
</code></pre>
<h3 id="34&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6570;&#x5B57;"><a name="34&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6570;&#x5B57;" class="anchor-navigation-ex-anchor" href="#34&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6570;&#x5B57;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7.2. 34.&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6570;&#x5B57;</h3>
<p>&#x65B9;&#x6CD5;&#x4E00;
&#x7528;*1&#x6765;&#x8F6C;&#x5316;&#x4E3A;&#x6570;&#x5B57;,&#x5B9E;&#x9645;&#x4E0A;&#x662F;&#x8C03;&#x7528;.valueOf&#x65B9;&#x6CD5;</p>
<pre><code class="lang-javascript"><span class="hljs-string">&apos;32&apos;</span> * <span class="hljs-number">1</span>            <span class="hljs-comment">// 32</span>
<span class="hljs-string">&apos;ds&apos;</span> * <span class="hljs-number">1</span>            <span class="hljs-comment">// NaN</span>
<span class="hljs-literal">null</span> * <span class="hljs-number">1</span>            <span class="hljs-comment">// 0</span>
<span class="hljs-literal">undefined</span> * <span class="hljs-number">1</span>    <span class="hljs-comment">// NaN</span>
<span class="hljs-number">1</span>  * { <span class="hljs-attr">valueOf</span>: <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span><span class="hljs-string">&apos;3&apos;</span> }        <span class="hljs-comment">// 3</span>
</code></pre>
<p>&#x65B9;&#x6CD5;&#x4E8C;</p>
<pre><code class="lang-javascript">+ <span class="hljs-string">&apos;123&apos;</span>            <span class="hljs-comment">// 123</span>
+ <span class="hljs-string">&apos;ds&apos;</span>               <span class="hljs-comment">// NaN</span>
+ <span class="hljs-string">&apos;&apos;</span>                    <span class="hljs-comment">// 0</span>
+ <span class="hljs-literal">null</span>              <span class="hljs-comment">// 0</span>
+ <span class="hljs-literal">undefined</span>    <span class="hljs-comment">// NaN</span>
+ { <span class="hljs-attr">valueOf</span>: <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span><span class="hljs-string">&apos;3&apos;</span> }    <span class="hljs-comment">// 3</span>
</code></pre>
<h3 id="35&#x5224;&#x65AD;&#x5C0F;&#x6570;&#x662F;&#x5426;&#x76F8;&#x7B49;"><a name="35&#x5224;&#x65AD;&#x5C0F;&#x6570;&#x662F;&#x5426;&#x76F8;&#x7B49;" class="anchor-navigation-ex-anchor" href="#35&#x5224;&#x65AD;&#x5C0F;&#x6570;&#x662F;&#x5426;&#x76F8;&#x7B49;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7.3. 35.&#x5224;&#x65AD;&#x5C0F;&#x6570;&#x662F;&#x5426;&#x76F8;&#x7B49;</h3>
<p>&#x80AF;&#x5B9A;&#x6709;&#x4EBA;&#x4F1A;&#x8BF4;&#x8FD9;&#x8FD8;&#x4E0D;&#x7B80;&#x5355;&#xFF0C;&#x76F4;&#x63A5;&#x7528;&apos;===&apos;&#x6BD4;&#x8F83;&#xFF1B;
&#x5B9E;&#x9645;&#x4E0A;0.1+0.2 !==0.3&#xFF0C;&#x56E0;&#x4E3A;&#x8BA1;&#x7B97;&#x673A;&#x4E0D;&#x80FD;&#x7CBE;&#x786E;&#x8868;&#x793A;0.1&#xFF0C; 0.2&#x8FD9;&#x6837;&#x7684;&#x6D6E;&#x70B9;&#x6570;&#xFF0C;&#x6240;&#x4EE5;&#x76F8;&#x52A0;&#x5C31;&#x4E0D;&#x662F;0.3&#x4E86;</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">Number</span>.EPSILON=(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{   <span class="hljs-comment">//&#x89E3;&#x51B3;&#x517C;&#x5BB9;&#x6027;&#x95EE;&#x9898;</span>
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Number</span>.EPSILON?<span class="hljs-built_in">Number</span>.EPSILON:<span class="hljs-built_in">Math</span>.pow(<span class="hljs-number">2</span>,<span class="hljs-number">-52</span>);
})();
<span class="hljs-comment">//&#x4E0A;&#x9762;&#x662F;&#x4E00;&#x4E2A;&#x81EA;&#x8C03;&#x7528;&#x51FD;&#x6570;&#xFF0C;&#x5F53;JS&#x6587;&#x4EF6;&#x521A;&#x52A0;&#x8F7D;&#x5230;&#x5185;&#x5B58;&#x4E2D;&#xFF0C;&#x5C31;&#x4F1A;&#x53BB;&#x5224;&#x65AD;&#x5E76;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7ED3;&#x679C;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">numbersequal</span>(<span class="hljs-params">a,b</span>)</span>{ 
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Math</span>.abs(a-b)&lt;<span class="hljs-built_in">Number</span>.EPSILON;
  }
<span class="hljs-comment">//&#x63A5;&#x4E0B;&#x6765;&#x518D;&#x5224;&#x65AD;   </span>
<span class="hljs-keyword">const</span> a=<span class="hljs-number">0.1</span>+<span class="hljs-number">0.2</span>, b=<span class="hljs-number">0.3</span>;
<span class="hljs-built_in">console</span>.log(numbersequal(a,b)); <span class="hljs-comment">//&#x8FD9;&#x91CC;&#x5C31;&#x4E3A;true&#x4E86;</span>
</code></pre>
<h3 id="36&#x53CC;&#x4F4D;&#x8FD0;&#x7B97;&#x7B26;"><a name="36&#x53CC;&#x4F4D;&#x8FD0;&#x7B97;&#x7B26;" class="anchor-navigation-ex-anchor" href="#36&#x53CC;&#x4F4D;&#x8FD0;&#x7B97;&#x7B26;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7.4. 36.&#x53CC;&#x4F4D;&#x8FD0;&#x7B97;&#x7B26;</h3>
<p>&#x53CC;&#x4F4D;&#x8FD0;&#x7B97;&#x7B26;&#x6BD4;Math.floor(),Math.ceil()&#x901F;&#x5EA6;&#x5FEB;</p>
<pre><code class="lang-javascript">~~<span class="hljs-number">7.5</span>                <span class="hljs-comment">// 7</span>
<span class="hljs-built_in">Math</span>.ceil(<span class="hljs-number">7.5</span>)       <span class="hljs-comment">// 8</span>
<span class="hljs-built_in">Math</span>.floor(<span class="hljs-number">7.5</span>)      <span class="hljs-comment">// 7</span>


~~<span class="hljs-number">-7.5</span>                <span class="hljs-comment">// -7</span>
<span class="hljs-built_in">Math</span>.floor(<span class="hljs-number">-7.5</span>)     <span class="hljs-comment">// -8</span>
<span class="hljs-built_in">Math</span>.ceil(<span class="hljs-number">-7.5</span>)      <span class="hljs-comment">// -7</span>
</code></pre>
<p>&#x6240;&#x4EE5;&#x8D1F;&#x6570;&#x65F6;&#xFF0C;&#x53CC;&#x4F4D;&#x8FD0;&#x7B97;&#x7B26;&#x548C;Math.ceil&#x7ED3;&#x679C;&#x4E00;&#x81F4;&#xFF0C;&#x6B63;&#x6570;&#x65F6;&#x548C;Math.floor&#x7ED3;&#x679C;&#x4E00;&#x81F4;</p>
<h3 id="37&#x53D6;&#x6574;&#x548C;&#x5947;&#x5076;&#x6027;&#x5224;&#x65AD;"><a name="37&#x53D6;&#x6574;&#x548C;&#x5947;&#x5076;&#x6027;&#x5224;&#x65AD;" class="anchor-navigation-ex-anchor" href="#37&#x53D6;&#x6574;&#x548C;&#x5947;&#x5076;&#x6027;&#x5224;&#x65AD;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7.5. 37.&#x53D6;&#x6574;&#x548C;&#x5947;&#x5076;&#x6027;&#x5224;&#x65AD;</h3>
<p>&#x53D6;&#x6574;</p>
<pre><code class="lang-javascript"><span class="hljs-number">3.3</span> | <span class="hljs-number">0</span>         <span class="hljs-comment">// 3</span>
<span class="hljs-number">-3.9</span> | <span class="hljs-number">0</span>        <span class="hljs-comment">// -3</span>

<span class="hljs-built_in">parseInt</span>(<span class="hljs-number">3.3</span>)  <span class="hljs-comment">// 3</span>
<span class="hljs-built_in">parseInt</span>(<span class="hljs-number">-3.3</span>) <span class="hljs-comment">// -3</span>

<span class="hljs-comment">// &#x56DB;&#x820D;&#x4E94;&#x5165;&#x53D6;&#x6574;</span>
<span class="hljs-built_in">Math</span>.round(<span class="hljs-number">3.3</span>) <span class="hljs-comment">// 3</span>
<span class="hljs-built_in">Math</span>.round(<span class="hljs-number">-3.3</span>) <span class="hljs-comment">// -3</span>

<span class="hljs-comment">// &#x5411;&#x4E0A;&#x53D6;&#x6574;</span>
<span class="hljs-built_in">Math</span>.ceil(<span class="hljs-number">3.3</span>) <span class="hljs-comment">// 4</span>
<span class="hljs-built_in">Math</span>.ceil(<span class="hljs-number">-3.3</span>) <span class="hljs-comment">// -3</span>

<span class="hljs-comment">// &#x5411;&#x4E0B;&#x53D6;&#x6574;</span>
<span class="hljs-built_in">Math</span>.floor(<span class="hljs-number">3.3</span>) <span class="hljs-comment">// 3</span>
<span class="hljs-built_in">Math</span>.floor(<span class="hljs-number">-3.3</span>) <span class="hljs-comment">// -4</span>
</code></pre>
<p>&#x5224;&#x65AD;&#x5947;&#x5076;&#x6570;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> num=<span class="hljs-number">5</span>;
!!(num &amp; <span class="hljs-number">1</span>) <span class="hljs-comment">// true</span>
!!(num % <span class="hljs-number">2</span>) <span class="hljs-comment">// true</span>
</code></pre>
<h2 id="boolean"><a name="boolean" class="anchor-navigation-ex-anchor" href="#boolean"><i class="fa fa-link" aria-hidden="true"></i></a>1.8. Boolean</h2>
<h3 id="38&#x5224;&#x65AD;&#x6570;&#x636E;&#x7C7B;&#x578B;"><a name="38&#x5224;&#x65AD;&#x6570;&#x636E;&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#38&#x5224;&#x65AD;&#x6570;&#x636E;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8.1. 38.&#x5224;&#x65AD;&#x6570;&#x636E;&#x7C7B;&#x578B;</h3>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">dataTypeJudge</span>(<span class="hljs-params">val, type</span>) </span>{
  <span class="hljs-keyword">const</span> dataType = <span class="hljs-built_in">Object</span>.prototype.toString.call(val).replace(<span class="hljs-regexp">/\[object (\w+)\]/</span>, <span class="hljs-string">&quot;$1&quot;</span>).toLowerCase();
  <span class="hljs-keyword">return</span> type ? dataType === type : dataType;
}
<span class="hljs-built_in">console</span>.log(dataTypeJudge(<span class="hljs-string">&quot;young&quot;</span>)); <span class="hljs-comment">// &quot;string&quot;</span>
<span class="hljs-built_in">console</span>.log(dataTypeJudge(<span class="hljs-number">20190214</span>)); <span class="hljs-comment">// &quot;number&quot;</span>
<span class="hljs-built_in">console</span>.log(dataTypeJudge(<span class="hljs-literal">true</span>)); <span class="hljs-comment">// &quot;boolean&quot;</span>
<span class="hljs-built_in">console</span>.log(dataTypeJudge([], <span class="hljs-string">&quot;array&quot;</span>)); <span class="hljs-comment">// true</span>
<span class="hljs-built_in">console</span>.log(dataTypeJudge({}, <span class="hljs-string">&quot;array&quot;</span>)); <span class="hljs-comment">// false</span>
</code></pre>
<p>&#x53EF;&#x5224;&#x65AD;&#x7C7B;&#x578B;&#xFF1A;undefined&#x3001;null&#x3001;string&#x3001;number&#x3001;boolean&#x3001;array&#x3001;object&#x3001;symbol&#x3001;date&#x3001;regexp&#x3001;function&#x3001;asyncfunction&#x3001;arguments&#x3001;set&#x3001;map&#x3001;weakset&#x3001;weakmap</p>
<h3 id="39&#x4F7F;&#x7528;boolean&#x8FC7;&#x6EE4;&#x6570;&#x7EC4;&#x5047;&#x503C;"><a name="39&#x4F7F;&#x7528;boolean&#x8FC7;&#x6EE4;&#x6570;&#x7EC4;&#x5047;&#x503C;" class="anchor-navigation-ex-anchor" href="#39&#x4F7F;&#x7528;boolean&#x8FC7;&#x6EE4;&#x6570;&#x7EC4;&#x5047;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8.2. 39.&#x4F7F;&#x7528;Boolean&#x8FC7;&#x6EE4;&#x6570;&#x7EC4;&#x5047;&#x503C;</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> compact = <span class="hljs-function"><span class="hljs-params">arr</span> =&gt;</span> arr.filter(<span class="hljs-built_in">Boolean</span>)
compact([<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-literal">false</span>, <span class="hljs-number">2</span>, <span class="hljs-string">&apos;&apos;</span>, <span class="hljs-number">3</span>, <span class="hljs-string">&apos;a&apos;</span>, <span class="hljs-string">&apos;e&apos;</span> * <span class="hljs-number">23</span>, <span class="hljs-literal">NaN</span>, <span class="hljs-string">&apos;s&apos;</span>, <span class="hljs-number">34</span>])  <span class="hljs-comment">//[ 1, 2, 3, &apos;a&apos;, &apos;s&apos;, 34 ]</span>
</code></pre>
<h3 id="40&#x77ED;&#x8DEF;&#x8FD0;&#x7B97;"><a name="40&#x77ED;&#x8DEF;&#x8FD0;&#x7B97;" class="anchor-navigation-ex-anchor" href="#40&#x77ED;&#x8DEF;&#x8FD0;&#x7B97;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8.3. 40.&#x77ED;&#x8DEF;&#x8FD0;&#x7B97;</h3>
<p>||&#xFF08;&#x6216;&#xFF09;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> flag = <span class="hljs-literal">false</span> || <span class="hljs-literal">true</span> <span class="hljs-comment">//true</span>
<span class="hljs-comment">// &#x67D0;&#x4E2A;&#x503C;&#x4E3A;&#x5047;&#x65F6;&#x53EF;&#x4EE5;&#x7ED9;&#x9ED8;&#x8BA4;&#x503C;</span>
<span class="hljs-keyword">const</span> arr = <span class="hljs-literal">false</span> || []
</code></pre>
<p>&amp;&amp;&#xFF08;&#x4E0E;&#xFF09;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> flag1 = <span class="hljs-literal">false</span> &amp;&amp; <span class="hljs-literal">true</span> <span class="hljs-comment">//false</span>
<span class="hljs-keyword">const</span> flag2 = <span class="hljs-literal">true</span> &amp;&amp; <span class="hljs-literal">true</span> <span class="hljs-comment">//true</span>
</code></pre>
<h3 id="41switch-&#x7B80;&#x5199;"><a name="41switch-&#x7B80;&#x5199;" class="anchor-navigation-ex-anchor" href="#41switch-&#x7B80;&#x5199;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8.4. 41.switch &#x7B80;&#x5199;</h3>
<p>&#x53EF;&#x4EE5;&#x7528;&#x5BF9;&#x8C61;&#x66FF;&#x4EE3;switch&#xFF0C;&#x63D0;&#x9AD8;&#x4EE3;&#x7801;&#x53EF;&#x8BFB;&#x6027;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">switch</span>(a) {
  <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;&#x5F20;&#x4E09;&apos;</span>:
    <span class="hljs-keyword">return</span> <span class="hljs-string">&apos;age&#x662F;12&apos;</span>
  <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;&#x674E;&#x56DB;&apos;</span>:
    <span class="hljs-keyword">return</span> <span class="hljs-string">&apos;age&#x662F;120&apos;</span>
}

<span class="hljs-comment">// &#x4F7F;&#x7528;&#x5BF9;&#x8C61;&#x66FF;&#x6362;&#x540E;</span>
<span class="hljs-keyword">const</span> obj ={
  <span class="hljs-string">&apos;&#x5F20;&#x4E09;&apos;</span>: <span class="hljs-string">&apos;age12&apos;</span>,
  <span class="hljs-string">&apos;&#x674E;&#x56DB;&apos;</span>: <span class="hljs-string">&apos;age120&apos;</span>,
}
<span class="hljs-built_in">console</span>.log(obj[<span class="hljs-string">&apos;&#x5F20;&#x4E09;&apos;</span>])
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; zhengyuliang all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x7F16;&#x5199;&#x65F6;&#x95F4;&#xFF1A;
2020-09-10 18:37:42
</span></footer></body></html>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="ES6汇总资料.html" class="navigation navigation-prev " aria-label="Previous page: ES6汇总资料">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="JavaScript之防抖Debounce和节流Throttle.html" class="navigation navigation-next " aria-label="Next page: JavaScript之防抖Debounce和节流Throttle">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"JS开发必须知道的41个技巧","level":"4.6","depth":1,"next":{"title":"JavaScript之防抖Debounce和节流Throttle","level":"4.7","depth":1,"path":"javaScript/JavaScript之防抖Debounce和节流Throttle.md","ref":"javaScript/JavaScript之防抖Debounce和节流Throttle.md","articles":[]},"previous":{"title":"ES6汇总资料","level":"4.5","depth":1,"path":"javaScript/ES6汇总资料.md","ref":"javaScript/ES6汇总资料.md","articles":[]},"dir":"ltr"},"config":{"plugins":["sectionx","splitter","tbfed-pagefooter","toggle-chapters","theme-comscore","-lunr","-search","search-plus","donate","anchor-navigation-ex","expandable-chapters","chapter-fold","expandable-chapters-small","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy zhengyuliang","modify_label":"该文件编写时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"pluginsConfig":{"anchor-navigation-ex":{"showLevel":false,"showGoTop":true,"isRewritePageTitle":true,"isShowTocTitleIcon":true,"tocLevel1Icon":"fa fa-hand-o-right","tocLevel2Icon":"fa fa-hand-o-right","tocLevel3Icon":"fa fa-hand-o-right"}},"livereload":{},"splitter":{},"donate":{"title":"","button":"赏","wechat":"https://gitee.com/htzyl/img_bed/raw/master/pay/weixin-min.jpg","alipay":"https://gitee.com/htzyl/img_bed/raw/master/pay/alipay-min.jpg","wechatText":"微信打赏","alipayText":"支付宝打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"sectionx":{"tag":"b"},"highlight":{},"anchor-navigation-ex":{"showLevel":true,"associatedWithSummary":true,"mode":"float","showGoTop":true,"printLog":false,"multipleH1":true,"float":{"floatIcon":"fa fa-navicon","showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""},"pageTop":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""}},"theme-comscore":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"zhengyuliang","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"记录技术文档内容","language":"zh-hans","gitbook":">=3.0.0","description":"记录Gitbook的配置和一些插件的使用","theme-default":{"showLevel":true}},"file":{"path":"javaScript/JS开发必须知道的41个技巧.md","mtime":"2020-09-10T10:37:42.293Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-01-06T09:44:01.178Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sectionx/sectionx.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

